Objective-C: How to read JSON?
I found this article about parsing JSON response from a URL request i iOS: http://www.raywenderlich.com/2965/how-to-write-an-ios-app-that-uses-a-web-service.
The article uses JSON Framework. I've downloaded the newest "SBJson_v3.0.4.zip" from the webpage and dragged in into a new group in my project. But then the build returns 62 errors like:
- ARC forbids explicit message send of 'release'
- Existing ivar 'delegate' for unsafe_unretained property 'delegate' must be __unsafe_unretained
- 'retain' is unavailable: not available in automatic reference counting mode
Does anybody know why? Is the JSON Framework not compatible with the newest Xcode?
Since iOS 5, iOS has its own JSON parser (thank you Twitter!)
NSError *err = nil; id result = [NSJSONSerialization JSONObjectWithData:data options:0 error:&err];
Do make sure to check the type of the output - it can be anything from a string to a number to a dictionary to an array.