• 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
NSWindow's setContentView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSWindow's setContentView


  • Subject: NSWindow's setContentView
  • From: Drarok Ithaqua <email@hidden>
  • Date: Mon, 19 Jun 2006 04:02:50 +0100

For sake of simplicity, let's assume I want to swap the contents of two windows, mainWindow and playlistWindow.

mainWindow contains an NSMovieView, and playlistWindow contains only an NSTableView. I run the following code:


NSView* playView = [playlistWindow contentView];
NSView* mainView = [mainWindow contentView];

// Assuming retainCount of 1 on both views to start with...
NSLog( @"main: %d. play: %d", [mainView retainCount], [playView retainCount] );


[playView retain]; // (2)
[mainView retain]; // (2)

[playlistWindow setContentView:mainView]; // playView gets a release (1), mainView a retain(3)
[mainWindow setContentView:playView]; // mainView gets a release(2), playView gets a retain(2).

[mainView release]; // (1)
[playView release]; // (1)

NSLog( @"main: %d. play: %d", [mainView retainCount], [playView retainCount] );


Debug says this:
2006-06-19 03:59:37.103 Flix[28513] main: 1. play: 1
2006-06-19 03:59:37.126 Flix[28513] main: 2. play: 2

And then, if I call that code again, I get a crash.
I'm assuming some autoreleasing is going on, but I really don't understand why the retainCounts are 2 when I think they should only be 1...


This probably seems pretty pointless, but it's the best way I can explain it at 4am.

Hope someone can shed some light, I'm tearing my hair out!



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • NSTableView controlTextDidChange:
      • From: Neto <email@hidden>
    • Re: NSWindow's setContentView
      • From: Shawn Erickson <email@hidden>
  • Prev by Date: Stopping an NSRunLoop OR getting NSDistributedNotificationCenter notifications
  • Next by Date: Re: NSWindow's setContentView
  • Previous by thread: Re: Stopping an NSRunLoop OR getting NSDistributedNotificationCenter notifications
  • Next by thread: Re: NSWindow's setContentView
  • Index(es):
    • Date
    • Thread