0

I have an array left over after parsing JSON that looks like ( -122.1407313, 37.7012704, 0 ) , How do I put them seperately into variables without an object or index to call? I tried:

NSArray *coordinates = [point objectForKey:@"coordinates"]; //holds the array above
NSString *lat = [coordinates objectAtIndex:0];
NSString *lon = [coordinates objectAtIndex:1];
3
  • What JSON parser are you using? If you got numbers in your JSON you might as well have NSNumber objects instead of NSStrings. What are the error messages? Commented Dec 29, 2011 at 22:37
  • Its SBJson, yeah, I should be using NSNumber, would this have an effect on it? No error messages. Commented Dec 29, 2011 at 22:42
  • I lied, its giving an uncaught exception: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSDecimalNumber length]: unrecognized selector sent to instance 0x47eeb50' Commented Dec 29, 2011 at 23:00

1 Answer 1

2

You want something like:

NSNumber *lat = (NSNumber*)[coordinates objectAtIndex:0];
float latValue = [lat floatValue];
Sign up to request clarification or add additional context in comments.

1 Comment

I am actually getting an error on build saying error: pointer value used where a floating point value was expected

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.