[英]iOS App Exception - Terminating app due to uncaught exception 'NSInvalidArgumentException'
I am getting the following exception, which is terminating the app. 我收到以下异常,该异常终止了该应用程序。
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayM objectForKey:]: unrecognized selector sent to instance 0x7abe4f90'
由于未捕获的异常“ NSInvalidArgumentException”而终止应用程序,原因:“-[__ NSArrayM objectForKey:]:无法识别的选择器已发送到实例0x7abe4f90”
Following is the code: 以下是代码:
- (NSMutableData*)dataForConnection:(URLConnection*)connection {
NSMutableData *data = [receivedData objectForKey:connection.tagKey]; // Exception Here
return data;
}
Could anyone please suggest how to fix it? 有人可以建议如何解决吗? Thank you in advance!
先感谢您!
[__NSArrayM objectForKey:]
NSArray
have not method called objectForKey:
NSArray
没有名为objectForKey:
方法objectForKey:
Your object receivedData
is NSArray
class , change to NSDictionary
. 你的目标
receivedData
是NSArray
类,变化NSDictionary
。
Problem is due to not allocating receivedData properly, since you have declared it as instance variable, so you should make it using the property declaration like this: 问题是由于未正确分配ReceivedData,因为您已将其声明为实例变量,因此应使用如下属性声明来使它:
@property(nonatomic, strong) NSMutableDictionary *receivedData;
This will ensure that receivedData does not get released and reference this using self.receivedData in your code. 这将确保receiveData不会被释放,并在代码中使用self.receivedData进行引用。 Maybe this is helpful
也许这是有帮助的
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.