[英]Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSDecimalNumber objectAtIndex:]
Hi I am getting this exception during execution of application. 嗨,我在执行应用程序时遇到此异常。
I have one service through that I want to insert device information to the sever. 我有一项服务,希望将设备信息插入服务器。 For this I have taken NSDictionary and I keep the value with following datatype like NSString, and one Long value. 为此,我采用了NSDictionary,并使用以下数据类型(如NSString)和一个Long值来保留该值。 once I try to insert the data it give the following error msg. 一旦我尝试插入数据,它将给出以下错误消息。
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSDecimalNumber objectAtIndex:] 由于未捕获的异常“ NSInvalidArgumentException”而终止应用程序,原因:“-[NSDecimalNumber objectAtIndex:]
Please help me on that thanks in Advance. 请提前帮助我。
I think you are trying to insert a C type in the dictionary. 我认为您正在尝试在字典中插入C类型。 NSDictionaries can only contain objects ( https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSDictionary_Class/Reference/Reference.html ): NSDictionaries只能包含对象( https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSDictionary_Class/Reference/Reference.html ):
To insert the long value as an object, you can make a NSNumber *n = [NSNumber numberWithLong:longValue]; 要将long值插入为对象,可以创建一个NSNumber * n = [NSNumber numberWithLong:longValue]; When you need to read it back, you can have [n longValue]. 当您需要将其读回时,可以具有[n longValue]。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.