I have a NSDictionary with some parameters I want to display in a UITextField. but
firstname.text = [userdata objectForKey:@"firstname"];
throws an exeption. If I use NSLog on [userdata objectForKey:@"firstname"]; it shows the right value.
This is the thrown exception:
2012-07-05 15:55:56.533 Project[13642:f803] -[__NSArrayM
_isNaturallyRTL]: unrecognized selector sent to instance 0x68c4e20 2012-07-05 15:55:56.534 Project[13642:f803] *** Terminating app due to
uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[__NSArrayM
_isNaturallyRTL]: unrecognized selector sent to instance 0x68c4e20’
If I use
firstname.text = [NSString stringWithFormat:@"%@",[userdata objectForKey:@"firstname"]];
it works, but it puts the values in brackets.
What seems to be the problem here? And why doesn’t the first attempt work?
is an undocumented NSString method. It seems that
is an NSMutableArray (guessed from class name), which you’re trying to use as a string. When you use a format string with the %@ format specifier, it calls the
-descriptionmethod of the object to be formatted/printed (so does NSLog), and the description of an NSArray is an NSString that looks likeetc., that’s why it puts your text in brackets but doesn’t crash.
All in all, use
instead.