NSString * a = @ "something";
NSString * b = [[NSString alloc] initWithFromat: @ "something"];
NSLog (@ "% d", [a retainCount]);
NSLog (@ "% d", [b retainCount]);
What are the specific differences between the above two assignment methods; and why the first number is very large, a novice again sincerely thank
Reply:
The first is a constant, there will be books on the basis of objective-c
Reply:
The first should be autorelease, the second is to manually release the memory
Reply:
NSString object type, it is a constant not correct, but the second floor of argument is correct, because the string instance "a" is a system initialization is completed, so bring a return AutoRelease (automatic release mechanism pool), and character Examples string "b" is instantiated and given initial manual, enough its reference base plus 1.
Reply:
If you want to test retain count, please do not take NSString test.
Reply:
The first one is the automatic release of the second memory address via a method first statement in the format string
Reply:
Those who do not explicitly write objects are created Alloc Autorelease object.
Reply:
< br />
Is this. First, the system will default to autorelease, to help you relieve it
The second, is to release his own
Reply:
+1
Reply:
Const string reference count is 0x7fffffff, which means that it is never released.
No comments:
Post a Comment