I have a question about the memory. According to the code & log below, is 0x6868190 a leak?
Code:
self.point = [NSString stringWithFormat:@"R"];
NSLog(@"********First********%d",[point retainCount]);
NSLog(@"********First********%p",point);
self.point = [NSString stringWithFormat:@"A"];
NSLog(@"********Second********%d",[point retainCount]);
NSLog(@"********Second********%p",point);
Log:
2012-04-17 20:27:49.838 test_[297:f803] ********First********2
2012-04-17 20:27:49.838 test_[297:f803] ********First********0x6868190
2012-04-17 20:27:49.839 test_[297:f803] ********Second********2
2012-04-17 20:27:49.839 test_[297:f803] ********Second********0x6879500
Use Instruments to check for memory leak. The fact that the retain count isn’t zero (or I guess you were expecting 1) doesn’t necessarily mean there is a leak. Those objects will be released at the end of the run loop if necessary.
The stringWithFormat call creates an object with a retain count of 1 (which will be auto-released). Then your property is probably declared as retain/strong, which adds one that will be released when your main object is released. Therefore it is two.