I've created UITabBarController programmatically, like this
mTabBarController = [[UITabBarController alloc] init];
...
NSLog(@"The ref count is : %d", [tabBarItems retainCount]);
mTabBarController.viewControllers = tabBarItems;
NSLog(@"The ref count is : %d", [tabBarItems retainCount]);
[tabBarItems release];
NSLog(@"The ref count is : %d", [tabBarItems retainCount]);
Also releasing mTabBarController in dealloc, like this,
- (void)dealloc {
[mTabBarController release];
...
}
Now the question : The output for the first code snippet is
2011-11-01 17:48:26.554 PostCardPrinter[12176:207] The ref count is : 1
2011-11-01 17:48:26.561 PostCardPrinter[12176:207] The ref count is : 1
2011-11-01 17:48:26.561 PostCardPrinter[12176:207] The ref count is : 1
Am I getting memory leak ? And why it prints 1 always ?
if it retains tabBarItems then the second output should be 2. If
mTabBarController.viewControllers = tabBarItems;
copies array items and retains each each array item then, the 3rd output should b 2 right ?
Do I get something wrong ???