有一种委托方法:
<div class="section">
<div class="container">
<div class="row">
<div class="col-md-12">
<form role="form" method="post" id="main-form" action="">
<div class="col-md-12 container-fluid row text-center">
<div class="form-group col-md-3">
<label class="" for="myList">*Item Name</label>
<br>
<select class="col-md-12 form-control" id="myList1" name="itemlist1" onChange="setItemUnit();showAmount();">
<option value="None">Select Items<br></option>
<option value="soap">Soap</option>
<option value="detergent">Detergent</option>
<option value="handwash">Hand Wash</option>
<option value="wire">Wire</option>
</select>
</div>
<div class="form-group col-md-2 text-center">
<label class="" for="unit1">UOM</label>
<p class="form-control text-right" id="unit1">NA</p>
</div>
<div class="form-group col-md-2 text-center">
<label class="control-label" for="rate1">*Rate/Unit</label>
<p class="form-control text-right" id="rate1">0</p>
</div>
<div class="form-group col-md-2 text-center">
<label class="control-label" for="qty1">*Ordered Qty</label>
<input class="form-control text-right" id="qty1" placeholder="0" type="number" onChange="showAmount();">
</div>
<div class="form-group col-md-3 text-center">
<label class="control-label" for="amt1">*Amount(Rs.)</label>
<p class="form-control text-right" id="amt1"></p>
</div>
</div>
<div class="col-md-12 container-fluid row text-justify">
<div class="form-group col-md-3">
<select class="col-md-12 form-control" id="myList2" name="itemlist2" onChange="setItemUnit2();showAmount();">
<option value="None">Select Items</option>
<option value="soap">Soap</option>
<option value="detergent">Detergent</option>
<option value="handwash">Hand Wash</option>
<option value="wire">Wire</option>
</select>
</div>
<div class="form-group col-md-2 text-center">
<p class="form-control text-right" id="unit2">NA</p>
</div>
<div class="form-group col-md-2 text-center">
<p class="form-control text-right" id="rate2">0</p>
</div>
<div class="form-group col-md-2 text-center">
<input class="form-control text-right" id="qty2" placeholder="0" type="number" onChange="showAmount();">
</div>
<div class="form-group col-md-3 text-center">
<p class="form-control text-right" id="amt2"></p>
</div>
</div>
<div class="col-md-12 container-fluid row text-justify">
<div class="form-group col-md-3">
<select class="col-md-12 form-control" id="myList3" name="itemlist3" onChange="setItemUnit3();showAmount();">
<option value="None">Select Items</option>
<option value="soap">Soap</option>
<option value="detergent">Detergent</option>
<option value="handwash">Hand Wash</option>
<option value="wire">Wire</option>
</select>
</div>
<div class="form-group col-md-2 text-center">
<p class="form-control text-right" id="unit3">NA</p>
</div>
<div class="form-group col-md-2 text-center">
<p class="form-control text-right" id="rate3">0</p>
</div>
<div class="form-group col-md-2 text-center">
<input class="form-control text-right" id="qty3" placeholder="0" type="number" onChange="showAmount();">
</div>
<div class="form-group col-md-3 text-center">
<p class="form-control text-right" id="amt3"></p>
</div>
</div>
<div class="col-md-12 container-fluid row text-justify" id="adder">
<div class="form-group col-md-12">
<button class="btn btn-block btn-primary" onclick="addNewItem();">Add more Items+</button>
</div>
</div>
<div class="col-md-12 container-fluid row text-justify">
<div class="form-group col-md-2 col-md-offset-7 text-center">
<label class="control-label text-primary" for="">*Total Qty</label>
<p class="form-control text-right" name="qty-total" id="qty-total"></p>
<!--<a class="btn btn-info btn-block"><p name="qty-total" id="qty-total"></p></a>-->
</div>
<div class="form-group col-md-2 text-center">
<label class="control-label text-primary" for="amt-total">*Total Amount(Rs.)Σ</label>
<p class="form-control text-right" name="amt-total" id="amt-total"></p>
<!--<a class="btn btn-info btn-block"><p name="amt-total" id="amt-total"></p></a>-->
</div>
</div>
</form>
</div>
</div>
</div>
</div>
...但它已被弃用,所以我用这个方法替换它:
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation
{
return [[FBSDKApplicationDelegate sharedInstance] application:application
openURL:url
sourceApplication:sourceApplication
annotation:annotation];
}
如何从NSDictionary中仅使用字符串对象,以及类似于id。
答案 0 :(得分:0)
这是Objective C轻量级泛型的语法。此功能主要用于修复Objective C - Swift互操作性问题。
NSDictionary<NSString *,id>
意味着,字典键应该是NSString类型,它的值可以是任何类型的对象(id)。
下面是从NSDictionary<NSString *,id>
获取值的示例,我希望这可以帮助您根据从Facebook登录获得的响应来提取NSString对象和id。
//Assign Generic Value.
float fltT = 98564.5f;
NSMutableDictionary<NSString *, id> *_generic;
_generic = [[NSMutableDictionary alloc] init];
_generic[@"genericValue"] = [NSNumber numberWithFloat:fltT];
NSLog(@"Assigned Generic Value:%@",_generic);
//Access generic values from NSMutableDictionary
NSLog(@"Access Generic Value:%@",_generic[@"genericValue"]);
这是输出日志: -
答案 1 :(得分:0)
您可以在方法内部进行日志记录或调试,并查看值。
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation{
NSLog(@"sourceApplication: %@,annotation: %@",sourceApplication,annotation);
//return ...
}
日志为:sourceApplication: com.apple.SafariViewService,annotation: (null)
在保留方法中:
-(BOOL) application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString *,id> *)options{
NSLog(@"%@", options);
//return ...
}
日志是:
UIApplicationOpenURLOptionsOpenInPlaceKey = 0;
UIApplicationOpenURLOptionsSourceApplicationKey = "com.apple.SafariViewService";
所以你可以像那样替换你的代码
return [[FBSDKApplicationDelegate sharedInstance] application:app
openURL:url
sourceApplication:[options valueForKey:@"UIApplicationOpenURLOptionsSourceApplicationKey"]
annotation:nil];
但我认为使用第一种方法是可以的,不需要使用这种方法:D 或者您可以在此链接上阅读有关Apple文档的更多信息:https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIApplicationDelegate_Protocol/index.html?hl=ar
快乐的编码;