我的网络服务有这个回复,但是UIAlertview发出了一个奇怪的错误
我打印了回复,就在下面我打电话
2013-08-13 15:40:27.463 Ipad Qld[1459:907] Result {
msg = "Form has been sent successfully.";
status = SUCCESS;
}
2013-08-13 15:40:27.465 Ipad Qld[1459:907] -[__NSDictionaryM isEqualToString:]: unrecognized selector sent to instance 0x1f1168e0
2013-08-13 15:40:27.467 Ipad Qld[1459:907] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSDictionaryM isEqualToString:]: unrecognized selector sent to instance 0x1f1168e0'
*** First throw call stack:
(0x32dad2a3 0x3ac1197f 0x32db0e07 0x32daf531 0x32d06f68 0x34bb9375 0x34d05c95 0x34d05741 0x6a25b 0x32cfe037 0x336ae2cb 0xa013f 0x9fe35 0x8d1e7 0x336e86fd 0x336281f9 0x33628115 0x32a8a45f 0x32a89b43 0x32ab1fcb 0x32cf374d 0x32ab242b 0x32a1603d 0x32d82683 0x32d81f7f 0x32d80cb7 0x32cf3ebd 0x32cf3d49 0x368aa2eb 0x34c09301 0x43a85 0x3b048b20)
libc++abi.dylib: terminate called throwing an exception
代码是
- (void) contactUsNotificationReceived:(NSNotification *) notification
{
[[ActivityIndicator currentIndicator] hide];
NSDictionary *alertMessage = [notification userInfo];
NSString * alertMessageString = alertMessage[@"NSLocalizedString"];
NSLog(@"Result is waga %@",alertMessageString);
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Result" message:alertMessageString delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
[alert show];
}
答案 0 :(得分:2)
看起来你正在传递NSDictionnary
。
一个猜测,试着改变:
NSString * alertMessage; // the object that you think is a NSString
到
NSDictionary * alertMessage;
NSString * alertMessageString = alertMessage[@"msg"];
祝你好运。
答案 1 :(得分:1)
您的代码在isEqualToString
中似乎有问题。源字符串无效或已释放,或者现在指向Dictionary
。
可能是您的提示字符串(您想要描述)它不是NSString
但可能是NSDictionary
,所以请检查它。
答案 2 :(得分:1)
首先从NSDictionary获取提醒消息到NSString ...
NSString *alertMessage = [yourDict objectForKey:@"yourKey"];
现在,在警报中显示您的提醒消息...
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:[NSString stringWithFormat:@"%@",alertMessage] message:nil delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
我希望这会对你有所帮助。