开发者

Why am I still getting retainCount=1, after releasing my objects

Why am I still getting retainCount = 1, after releasing my objects.

This is my code. Can any one help me to fix this:

    newsDetail *newsdetails = [[newsDetail alloc] initWithNibName:@"newsDetail" bundle:nil];
    [newsdetails insertSomeData];

    NSLog(@"Object Count in memmory = %d",[newsdetails retainCount]);

    [self.view addSubview:newsdetails.view];
    NSLog(@"Object Count in memmory = %d",[newsdetails retainCount]);

    [newsdetails release];
    NSLog(@"Object Count in memmory = %d",[newsdetails retainCount]);

........

2011-09-20 10:26:10.208 memmory[1977:207] Object Count in mem开发者_JS百科mory = 1
2011-09-20 10:26:10.212 memmory[1977:207] Object Count in memmory = 1
2011-09-20 10:26:10.213 memmory[1977:207] Object Count in memmory = 1


The alloced object is retained, hence retain = 1; addSubview increases retain count by one, you decrease the retain by one in release call.


When you add a view as a subview somewhere then this view is retained.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜