Created
May 5, 2011 05:07
-
-
Save jspahrsummers/956568 to your computer and use it in GitHub Desktop.
Following this behavior, how would you want to write it naturally?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (NSString *)myMethod { | |
NSString *str = nil; | |
scope { | |
NSAutoreleasePool *pool = [NSAutoreleasePool new]; | |
scope(exit) | |
[pool drain]; | |
str = [[NSMutableString alloc] initWithFormat:@"%i", 42]; | |
for (int i = 0;i < 10;++i) | |
scope { | |
NSString *append = [something thatReturnsACopy]; | |
scope(exit) { | |
[append release]; | |
} | |
[str appendString:append]; | |
} | |
} | |
return [str autorelease]; | |
} | |
- (void)myOtherMethod { | |
scope { | |
NSAutoreleasePool *pool = [NSAutoreleasePool new]; | |
scope(exit) | |
[pool drain]; | |
NSString *str = [NSString stringWithFormat:@"%i", 42]; | |
if ([str length]) { | |
// done | |
return; | |
} | |
[self doMoreStuff]; | |
if (done) | |
return; | |
[self doEvenMoreStuff]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment