NSLog(@"retain count 1 for show detail -- %d",[showDetail retainCount]);
ChecklistDetail *detail = [appDelegates.arrayForChecklistDetails objectAtIndex:[sender tag]];
self.showDetail = detail;
NSLog(@"retain count 2 for show detail -- %d",[showDetail retainCount]);
Here, in the above code, output of the first nslog is "retain count 1 for show detail -- 0", which is correct. However, the output of the second nslog comes as following "retain count 2 for show detail -- 2".
How does its retain count go upto 2?
help me if u can....
to check the Retain counts and proper memory management of variables in iOS, please use Instruments and do not check the Retain count facility as it is not very trustful.
To start using Instruments in Xcode 4, keep holding the Run button on the top left corner and then press on profile. This will make the Instruments come up.
Then there are two sections, which are Allocations and Leaks. Here, you can check the memory allocations and management of the variables.
Enjoy coding...! :)