Re: Getting a reference to the data model from a delegate
Re: Getting a reference to the data model from a delegate
- Subject: Re: Getting a reference to the data model from a delegate
- From: Rob In der Maur <email@hidden>
- Date: Mon, 20 Jan 2003 09:26:09 +0100
Thanks for all the answers sofar. Bill's recommendation of using a
reference to the window controller when initialising the delegate is
one of the solutions I thought of.
Now quoting James answer to my question...
Rob's problem is getting a reference to his data model from a nib
instantiated object (his table view's delegate).
From: Bill Cheeseman <email@hidden>
Your question is a little confusing since you don't say (in the
excerpt I
saw) whether the delegate is the NSWindowController subclass. But it
doesn't
really matter.
Rob did say that his delegate is a separate object and that his window
controller is acting as his table view's data source. His current code
uses this technique:
From: Rob In der Maur <email@hidden>
As my datasource methods are defined in my dedicated window
controller class, ..., I'm using:
DataModel *dataModel = [[[aTable dataSource] document]
dataModel];
to give me a reference back to the data model. Works fine for the
moment....
For clarification: that is the code I use in the delegate class to get
a hook to my data model.
This statement defines his problem more clearly: Rob's code needs a
reference to his window controller to get access to his data; if (data
source != window controller), he can't find his window controller (is
there any way to get from window to window controller without using
your document controller?).
James, thanx for your clear redefinition...!
I'm guessing that his delegate is in a nib file (separate from his
document's main nib file) and that his window controller is this nib's
file's owner. Given an object in a document's main nib can find its
document and that Rob's window controller has connections to his table
view:
The delegate is in the same nib file as the document's main nib file.
My custom class for the file's owner is indeed my subclass of
NSWindowController.
W.r.t. your suggestion, I'm a bit confused but are you basically saying
that one way to solve this is define an outlet in my delegate class
that points to the File's Owner (which is my dedicated window
controller) in the nib file? Does seem to make sense to me, but I just
want to know whether I'm interpreting your suggestion correctly.
Thanks
Rob
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.