For ease of use, I am writing an SBJsonParser category with the name Add-on:
@implementation SBJsonParser(Addition) + (NSDictionary *)parseJson:(NSData *)data { SBJsonParser *parser = [[SBJsonParser alloc] init]; NSDictionary *dict = [parser objectWithData:data]; [parser release]; return dict; } @end
My questions:
It looks good if you know for sure that the JSON data contains a dictionary, not an array.
No and no. parser is local and does not need anything else if the -objectWithData: method is synchronous.
parser
-objectWithData:
Yes.
It looks well formed and overall correct.
You do not need to use a static keyword for the parser in this case.
Yes, you need to free the parser, and you did it in the right place.
1) looks good
2) it is not. You should not.
3) this is normal since it
It's good. Parser is not a status, it is a regular local variable, but since you generally release it, then what. Yes, the parser must be released