The error:
Code:
[__NSArrayI substringFromIndex:]: unrecognized selector sent to instance 0x266a60
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI substringFromIndex:]: unrecognized selector sent to instance 0x266a60'
*** First throw call stack:
(0x329e8d2f 0x3114b0e3 0x329eca45 0x329ebc23 0x32966d10 0x2b79 0xc9bf 0xe1d3 0x368d9e49 0x368d972b 0x368d8f4d 0x368d96d3 0x368d97bb 0x368321c7 0x35e4e17d 0x35e4320b 0x35e43335 0x35e42e33 0x35ed8465 0x35e42d59 0x35e42cd1 0x329b30f5 0x329b4827 0x329b57b3 0x32953c43 0x32953b05 0x3433c27b 0x3433c311 0x33167127 0x331642a5 0x2681 0x2618)
NSLog:
Code:
0
(
{
balance = "1029.20387";
}
)
Based on this information, I suspect the following code is making a deeply flawed assumption:
Code:
NSString *theString = [object2 objectForKey:@"data"];
I don't think it's returning an NSString at all. I think it's returning an NSArray.
When used with the %@ print format, an NSArray will show a list of its values enclosed in parentheses. Exactly as shown.
Furthermore, I suspect there's one element in the NSArray, and it's an NSDictionary. Because an NSDictionary will print its key/value pairs enclosed in { }s. Exactly as shown.
Within that NSDictionary, there is a single key "balance", whose value is a string "1029.20387" (type NSString*). I can tell it's a string because it's quoted. If it were an NSNumber, it wouldn't be quoted.
FWIW, I suspect [NSScanner scannerWithString:theString] doesn't fail only because scannerWithString: doesn't actually do anything with its argument until later.
So I think you need to explain how object2 gets its value.
You should also look at some of the NSObject methods that return the class of an object, and work out some way to identify what type is being used at each relevant point in the assignment of a value to object2.