studying some sample code from an iOS programming course (cs193p fall2010) i came across
the sbjson framework which extends NSObject etc. by a category named SBJSON.
but in the +header “NSObject+SBJSON.h” it reads as:
@interface NSObject (NSObject_SBJSON)
where does the magic mapping of NSObject_SBJSON to SBJSON come from?
i noticed xcode accepting any string before the underline !?
but nowhere found a hint on that.
thanx
klaus
There isn’t really a mapping, per se. An Objective-C category is used to add additional methods to an existing class, without needing direct access to that class’s corresponding implementation file/details. So when you declare something like:
You are saying that your category adds methods to the
NSObjectclass (and any class derived from it). The “NSObject_SBJSON” part in parenthesis is not really significant, and can be anything you like (so long as it doesn’t collide with the name of anyone else’s category for that object type). It does not even need to include “NSObject”, so having@interface NSObject (SBJSON)would be equally valid.