Another strange thing, this time on retainCount
Another strange thing, this time on retainCount
- Subject: Another strange thing, this time on retainCount
- From: Stéphane Sudre <email@hidden>
- Date: Fri, 25 May 2001 18:38:04 +0200
From what I'm seeing (from a lot of NSLog), [NSView removeFromSuperview]
doesn't decrease (instantly ?) the retainCount of the NSView.
NSLog(@"Remove\n");
NSLog([[NSNumber numberWithInt:[currentTabView_ retainCount]]
stringValue]);
[currentTabView_ removeFromSuperview];
NSLog([[NSNumber numberWithInt:[currentTabView_ retainCount]]
stringValue]);
produces this result:
Remove
May 25 18:21:54 StupidTest[6575] 5
May 25 18:21:54 StupidTest[6575] 5
Another strange thing is that if I have a NSView with a retainCount of 1
and do the following thing;
NSLog([[NSNumber numberWithInt:[currentTabView_ retainCount]]
stringValue]);
[[IBwindow_ contentView] addSubview:currentTabView_];
NSLog([[NSNumber numberWithInt:[currentTabView_ retainCount]]
stringValue]);
[currentTabView_ setFrameOrigin:tOrigin];
[currentTabView_ release];
The application crashes.
The result is yet:
May 25 18:22:46 StupidTest[6577] 1
May 25 18:22:46 StupidTest[6577] Add
May 25 18:22:46 StupidTest[6577] 2
So with a release I should get a retainCount of 1 so the view should
still be there.
This leads me to do some workaround and get a retainCount which is
always increasing.