• 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: Newbie problem with opening new windows and using bindings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Newbie problem with opening new windows and using bindings


  • Subject: Re: Newbie problem with opening new windows and using bindings
  • From: Jonathon Mah <email@hidden>
  • Date: Thu, 14 Apr 2005 03:07:04 +0930

Hi Kane,


On 14 Apr 2005, at 02:26, Kane Dijkman wrote:

ListEditorController * lec = [[ListEditorController alloc] init];

NSString * listPath = [[self getPreference:@"pathToLists"] stringByAppendingPathComponent:[[self getSelectedListNames] objectAtIndex:0]];

		[lec openList:listPath];

[lec release];

You probably shouldn't be releasing the ListEditorController here. Instead, you should add it to an array of controllers and remove it when the window is closed. (Perhaps you could have the ListEditorController send out a notification with NSNotificationCenter when its window closes, and listen for that notification in your main controller.)


In IB for the ListEditor.nib I have the File's Owner as the Controller. and under NSResponder:NSWindowController I have the ListEditorController.

I'm not quite sure what you mean here. So ListEditorController is a subclass of NSWindowController? That's fine*. You also need to click on "File's Owner", go to "Custom Class" in the inspector and change its class to ListEditorController, if you haven't already.


With using bindings or not I am having the same question:
Without bindings: How can I create an Outlet in the ListEditorController and connect it to the NSTextView i have in the new window? I tried instantiating the ListEditorController but once I do I get an error and the app does not run.

Instantiating the ListEditorController in the nib would cause its -init method to run, which will open another copy of the nib and instantiate another ListEditorController, which would open another copy of the nib and... etc. You'd probably run out of memory very soon.


When I try to connect the NSTextView to the outlet I created in ListEditorController I can not, because all I see are the Controller values.

You need to create an outlet in ListEditorController. Once File's Owner is set to ListEditorController, you can control-drag from File's Owner to the object you want. The ListEditorController you made at the beginning (that loaded the nib) would then have its outlets set up.


For bindings: I am not even sure exactly what to ask... but I think it what I want is to create an NSObjectController and bind it to a variable in ListEditorController, but as with the non binding method, I am not able to see any of the ListEditorController variables.

What are you trying to do? Have a binding from the NSTextView to the contents of the file you selected at the beginning? Hopefully your outlets now work, so this shouldn't be too much of a problem.


(As an aside, there is a bug with bindings that cause a memory leak when you bind through File's Owner. At the moment your top priority is probably just getting the app to work, so don't worry about it. You can find some more discussion on it on the web, including a fix.)

So, in summation I am trying to have a second controller in this application that is instantiated and used with a separate nib/window. While I could create all the code and have it work in the main controller I want to avoid this since that would make the Controller file really big by the time everything is done.

Yep, two controller classes (with one main controller, and lots of instances of the edit controller) is a good approach.


Is the approach I am using even correct? Am I creating the ListEditorController and opening the window properly? In the books I have and online examples I have seen all I ever see are new windows being created that are controlled by the main controller. So am I totally off in my thinking that a separate controller for a window that has a specific function is the best way to go?

* Your ListEditController should probably be a subclass of NSWindowController. If it is, you don't need your custom -init code. Instead, create a controller with: << ListEditController *lec = [[ListEditController alloc] initWithWindowNibName:@"ListEditor"]; >> (which will load the nib and set 'lec' to be File's Owner). Subclassing NSWindowController will give you some other handy features too. Take a look at its docs.



Jonathon Mah email@hidden

_______________________________________________
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


References: 
 >SIGSEGV in NSEPSImageRep imageRepWithData (From: Stefan Landvogt <email@hidden>)
 >Re: SIGSEGV in NSEPSImageRep imageRepWithData (From: j o a r <email@hidden>)
 >Newbie problem with opening new windows and using bindings (From: Kane Dijkman <email@hidden>)

  • Prev by Date: Re: Tiger development Panther deployment
  • Next by Date: Re: When do table column bindings get setup from nib?
  • Previous by thread: Newbie problem with opening new windows and using bindings
  • Next by thread: CGDisplayBaseAddress
  • Index(es):
    • Date
    • Thread