• 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
Re: NSTableView retain count problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTableView retain count problem


  • Subject: Re: NSTableView retain count problem
  • From: Shane <email@hidden>
  • Date: Mon, 23 Nov 2009 21:43:12 -0600

> There are two self's, I.e. two different instances.  The name 'self' isn't a
> single variable.  It represents the object that's responding to the message,
> and executing the method.
>
> My guess is that one instance is created in the nib, and the other is
> created in code you wrote.
>
> Use the debugger.  Set a breakpoint on the init methods and look at how it
> reaches that point.

I'm still trying to hunt down the second instance of 'self' that I'm
seeing but I don't understand something here.

@interface AppController : NSWindowController
{
	MainViewController *mvc;
	NSMutableArray *mainViewControllers;
}
…

@implementation AppController
- (id) init
{
	...
	mainViewControllers = [[NSMutableArray alloc] init];

	// This is the 1st and should be only instance I create.

	mvc = [[DataViewController alloc] initWithController:self];
	[mainViewControllers addObject:mvc];
	[mvc release];
	...
}

- (void) awakeFromNib
{
	[self displayViewController:[mainViewControllers objectAtIndex:0]];
}

- (void) displayViewController:(MainViewController *) mvc
{
	NSWindow *win = [box window];
	BOOL ended = [win makeFirstResponder:win];

	if (!ended) {
		NSBeep();

		return;
	}

        // This is calling the 2nd instance which I can see w/ the debugger.
	NSView *mv = [mvc view];

	[box setContentView:mv];
}
@end

When I'm viewing the call stack in the debugger, I see that my
DataViewController's init method is called a second time from the line
… "NSView *mv = [mvc view]".

I'm doing view swapping just as is done in Hillegass's 3rd. ed. book.
So my DataViewController is subclassed from a MainViewController which
is an NSViewController.

I looked at the NSViewController docs but didn't anything about why
[NSViewController view] would send an init msg to the receiver.
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: NSTableView retain count problem
      • From: Kyle Sluder <email@hidden>
References: 
 >Re: NSTableView retain count problem (From: Greg Guerin <email@hidden>)

  • Prev by Date: Re: Strings mangled on generalPasteboard
  • Next by Date: Re: NSTableView retain count problem
  • Previous by thread: Re: NSTableView retain count problem
  • Next by thread: Re: NSTableView retain count problem
  • Index(es):
    • Date
    • Thread