• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Another strange thing, this time on retainCount
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


  • Follow-Ups:
    • Re: Another strange thing, this time on retainCount
      • From: Greg Betzel <email@hidden>
  • Prev by Date: Re: Variables of N bits in size
  • Next by Date: Re: NSMenuItem: [ ] Bug [ ] Unexpected Behavior [ ] Answer forthcoming
  • Previous by thread: Re: NSMenuItem: [ ] Bug [ ] Unexpected Behavior [ ] Answer forthcoming
  • Next by thread: Re: Another strange thing, this time on retainCount
  • Index(es):
    • Date
    • Thread