Looking at the source of the JSON-Framework, it makes heavy use of skip by reference in many parser method signatures. i.e.
@interface SBJsonParser ()
- (BOOL)scanValue:(NSObject **)o;
- (BOOL)scanRestOfArray:(NSMutableArray **)o;
- (BOOL)scanRestOfDictionary:(NSMutableDictionary **)o;
@end
The result is something like this:
id o;
[self scanValue:&o];
- (BOOL)scanValue:(NSObject **)o {
return [self scanRestOfDictionary:(NSMutableDictionary **)o];
}
- (BOOL)scanRestOfDictionary:(NSMutableDictionary **)o {
*o = [NSMutableDictionary dictionaryWithCapacity:7];
[*o setObject:@"value" forKey:@"key"];
return YES;
}
What are the benefits of this approach?
EDIT: I ask more in terms of design. I understand what follows the link, I'm just wondering when it makes sense to use it. The design used in SBJsonParseris similar to the API used in NSScanner:
- (BOOL)scanUpToString:(NSString *)stopString intoString:(NSString **)stringValue;
For me, this means that the line that was scanned is secondary to the need to know if something was scanned. This is different from the API used NSString:
+ (id)stringWithContentsOfFile:(NSString *)path encoding:(NSStringEncoding)enc error:(NSError **)error;
API , NSError , - .
, API , .