简体   繁体   中英

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. once I try to insert the data it give the following error msg.

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSDecimalNumber objectAtIndex:]

Please help me on that thanks in Advance.

I think you are trying to insert a C type in the dictionary. NSDictionaries can only contain objects ( 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

To insert the long value as an object, you can make a NSNumber *n = [NSNumber numberWithLong:longValue]; When you need to read it back, you can have [n longValue].

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM