some time ago I was figuring out JSON handling in Objective-C (iPhone) and I found one confusing thing there.
This call puzzles me:
NSString* jsonString = [jsonDict JSONRepresentation];
In fact jsonDict
is an instance of NSDictionary
class and according to NSDictionary Class Reference NSDictionary does not have this JSONRepresentation
method. I feel cheated somewhere, I know that it works but can't figure out how.
Can anyone explain?
Thanks
This is an example of a "Category", which is a way to add methods to existing classes.
http://developer.apple.com/library/ios/#documentation/general/conceptual/DevPedia-CocoaCore/Category.html
Take a look at JSON Framework this method came from.
The framework puts a category on NSDictionary. Categories are used to add extra methods to a class. More info on how categories work an are implemented is in the docs. Now that you know the right term for it it should be easy to find.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With