【发布时间】:2018-09-15 01:03:41
【问题描述】:
当我将数据传递到 PushNotificationManager 时,提示错误如下。
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSSingleObjectArrayI un_stringWithMaxLength:]: unrecognized selector sent to instance 0x604000018550'
这是我的代码:-
[self.manager GET:@"http://api.xxxx.com/api/promotion/1" parameters:nil progress:nil success:^(NSURLSessionDataTask *task, id responseObject) {
json_promotion = responseObject;
[[UNUserNotificationCenter currentNotificationCenter] setDelegate:self];
NSString *strProTitle = [json_promotion valueForKey:@"title"];
NSLog(@"strProTitle - %@",strProTitle);
//Will get string "Promotion Today!" which is CORRECT
//If i put NSString *strProTitle = @"testing here", error will not appear.
[[PushNotificationManager sharedInstance]graphicsPushNotificationWithTitle:strProTitle subTitle:@"text here" body:@"desc here" identifier:@"2-1" fileName:@"Graphics.jpg" timeInterval:3 repeat:NO];
有什么想法吗?请帮忙。
【问题讨论】:
-
如果您是首次亮相,请避免使用
valueForKey:。该问题与此stackoverflow.com/a/49666984/1801544 有关(用于错误说明) -
嗨拉姆,感谢您的提示。我现在避免使用 valueForKey。
标签: ios objective-c push-notification nsstring