, , . , , , .
NSArray. . Objective C. - , componentsJoinedByString, NSStrings g. genArray , id ^(). , . - :
+ (id) genArray: (id^()) gen;
+ (id) genString {
...
NSString * (^g)() = ^() {
return [NSString stringWithFormat:@"%c", [ObjCheck genChar]];
};
...
}
NSString * - . char . NSString * ^() id ^(), char ^() id ^(). genArray char ^(), genArray, genArray, arrayByAddingObject, .
Someone who understands the subtleties of block syntax can edit my post if I get some subtle syntax errors.
Btw, use NSMutableArray as a local variable in genArray. Presenting, arrayByAddingObject is called again and again, will have O (n ^ 2) performance. You can still declare the return type as NSArray, which is the superclass of NSMutableArray, and the calling genArray elements will not know the difference.
source
share