简体   繁体   English

由于未捕获的异常“ NSInvalidArgumentException”而终止应用程序,原因:“-[NSDecimalNumber objectAtIndex:]

[英]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 ):

  • (void)setValue:(id)value forKey:(NSString *)key <-- the value must be an object (void)setValue:(id)value forKey:(NSString *)key <-该值必须是一个对象

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.

相关问题 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“-[__NSCFString isDescendantOfView:]: - Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString isDescendantOfView:]: 由于未捕获的异常&#39;NSInvalidArgumentException&#39;而终止应用程序,原因:&#39;-[QBDDXMLElement attributeFloatValueForName:withDefaultValue:]: - Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[QBDDXMLElement attributeFloatValueForName:withDefaultValue:]: 错误:由于未捕获的异常&#39;NSInvalidArgumentException&#39;而终止应用程序,原因:&#39; - [NSCFNumber isEqualToString:]: - Error:Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFNumber isEqualToString:]: 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“-[NSCFString nric]: - Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFString nric]: 由于未捕获的异常&#39;NSInvalidArgumentException而终止应用程序 - Terminating app due to uncaught exception 'NSInvalidArgumentException 由于未捕获的异常“ NSInvalidArgumentException”而终止应用程序 - Terminating app due to uncaught exception 'NSInvalidArgumentException' 由于未捕获的异常“ NSInvalidArgumentException”而终止应用程序, - Terminating app due to uncaught exception 'NSInvalidArgumentException', (由于未捕获的异常&#39;NSInvalidArgumentException而终止应用程序) - (Terminating app due to uncaught exception 'NSInvalidArgumentException) 由于未捕获的异常“ NSInvalidArgumentException”而终止应用程序 - Terminating app due to uncaught exception 'NSInvalidArgumentException' ***由于未捕获的异常&#39;NSRangeException&#39;而终止应用程序,原因:&#39;***-[NSMutableArray objectAtIndex:]:索引1超出范围[0 .. 0]&#39; - *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSMutableArray objectAtIndex:]: index 1 beyond bounds [0 .. 0]'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM