• 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
Getting a reference to the data model from a delegate
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Getting a reference to the data model from a delegate


  • Subject: Getting a reference to the data model from a delegate
  • From: Rob In der Maur <email@hidden>
  • Date: Tue, 14 Jan 2003 19:06:48 +0100

Hi All,

First of all, many thanks for this list and your contributions. Alongside the books I've bought, this list is of tremendous help for me in understanding Cocoa.

Now my question:
I'm having problems getting a reference back to my data model from a delegate in a document based application, which also has a dedicated NSWindowController class.

Let me explain. I have a drawer in which I display a table. To have the table display its cell properly and to have it react properly on editing its cells I've defined the methods like
- (void)tableViewSelectionIsChanging:(NSNotification *)aNotification
- (void)tableViewSelectionDidChange:(NSNotification *)aNotification
- (BOOL)control:(NSControl *)control textShouldEndEditing:(NSText *)fieldEditor
- (void)controlTextDidEndEditing:(NSNotification *)aNotification
in a seperate delegate class.

In order to display things properly I have to refer to my data model which is tied to my document.
For the moment I use a trick. As my datasource methods are defined in my dedicated window controller class, which (obviously) has an outlet to the respective table, I'm using:
DataModel *dataModel = [[[aTable dataSource] document] dataModel];
to give me a reference back to the data model. Works fine for the moment....

But in order to tidy things up, I'm considering moving my datasource methods also in a seperate class. With that I will lose my 'reference point' to the window controller and hence my document and data model.

I also tried to get to my document through my window controller by calling [[aTable window] parentWindow] but that doesn't seem to work properly.

I have the suspicious feeling I'm overlooking something very obvious so help is appreciated...!

Thanks in advance...

cheers

o#?
Rob In der Maur
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Getting a reference to the data model from a delegate
      • From: James DiPalma <email@hidden>
  • Prev by Date: Re: Bottom part of the Interface Builder size inspector and window
  • Next by Date: Re: NSTask Path
  • Previous by thread: Re: NSTask Path
  • Next by thread: Re: Getting a reference to the data model from a delegate
  • Index(es):
    • Date
    • Thread