Created
March 12, 2012 03:18
-
-
Save amachang/2019501 to your computer and use it in GitHub Desktop.
How to debug Retain Count and Autorelease Count on Objective-C
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*) stringEncodedPercentWithString:(NSString*)source | |
{ | |
NSString *encodedString = (NSString *)CFURLCreateStringByAddingPercentEscapes(NULL, (CFStringRef)source, NULL, (CFStringRef)@"!*'();:@&=+$,/?%#[]", kCFStringEncodingUTF8); | |
[encodedString autorelease]; | |
// Show target's memory address. | |
NSLog(@"encodedString address = 0x%p", encodedString); | |
// Show target's autorelease count | |
[NSAutoReleasePool showPools]; | |
// Show target's retain count | |
NSLog(@"encodedString retainCount = %ld", [encodedString retainCount]); | |
// break here | |
assert(false); | |
return encodedString; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment