简体   繁体   English

iOS应用程序异常-由于未捕获的异常'NSInvalidArgumentException'而终止应用程序

[英]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 . 你的目标receivedDataNSArray类,变化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.

相关问题 iOS - 由于未捕获的异常'NSInvalidArgumentException'而终止应用程序 - iOS - Terminating app due to uncaught exception 'NSInvalidArgumentException' 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序 - ios google 登录 - Terminating app due to uncaught exception 'NSInvalidArgumentException' - ios google sign in “因未捕获的异常而终止应用程序'NSInvalidArgumentException'” - “Terminating app due to uncaught exception 'NSInvalidArgumentException'” 由于未捕获的异常'NSInvalidArgumentException 4而终止应用程序 - Terminating app due to uncaught exception 'NSInvalidArgumentException 4 ***由于未捕获的异常'NSInvalidArgumentException'而终止应用, - *** Terminating app due to uncaught exception 'NSInvalidArgumentException', 由于未捕获而终止应用程序 > 异常“NSInvalidArgumentException” - Terminating app due to uncaught > exception 'NSInvalidArgumentException' 由于未捕获的异常“ NSInvalidArgumentException”而终止应用程序,NSUserDefaults? - Terminating app due to uncaught exception 'NSInvalidArgumentException', NSUserDefaults? 由于未捕获的异常“ NSInvalidArgumentException”而终止应用程序, - Terminating app due to uncaught exception 'NSInvalidArgumentException', 由于未捕获的异常NSInvalidArgumentException而终止应用程序 - Terminating app due to uncaught exception NSInvalidArgumentException 由于SDWEbImage中未捕获的异常'NSInvalidArgumentException'而终止应用 - Terminating app due to uncaught exception 'NSInvalidArgumentException' in SDWEbImage
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM