Re: set***Value: Method not working
Re: set***Value: Method not working
- Subject: Re: set***Value: Method not working
- From: Jeremy Dronfield <email@hidden>
- Date: Mon, 1 Jul 2002 14:59:16 +0100
I've made it work!!!!!!!!
I didn't actually use your suggestions (I did play around with them),
but it was neverthless your suggested approaches that led me to the
cause of the problem - the failure to create an instance of sRControls
in the SRBookmarkController instance - and a solution. In the end, I put
this in SRControls.m (at the end of the method that launches
SRBookmarkController):
[bookmarkController setSRControls:self];
... and a corresponding method in SRBC:
- (void)setSRControls:(SRControls *)value {
sRControls = value;
}
- (SRControls *)sRControls {
return sRControls;
}
... and bingo! I can now pass values back from SRBC to sRControls. I
didn't put anything at all in SRBC's init method. (If that's breaking
some Cocoa coding etiquette, I don't care just at this minute. I'll get
back to it later.)
Thanks again for your help
- Jeremy.
On Sunday, June 30, 2002, at 11:02 pm, email@hidden wrote:
Ok.. more stupid questions..
HOW did you set the NSApp delegate?? Are you sure its set? :-)
You generally need to set it in the "applicationWillFinishLoading
notification" or something like that..
and in that method do a [ NSApp setDelegate: self ] .. ..
Yes.. passing objects around is pretty easy as long as one object
knows the other object..
Generally it is done by having the object that creates an instance of
the other object pass itself it
via a special "initWithFoo: self" sort of call or something.. that way
the new object knows who its
"owner" is.. (or a setOwner: ) method or something in the controller
app...
So.. In your case in the SRBookmakrController I would code a
initWithSRControl: mySRControl
and then do
[ super init ] ;
sRControls = mySRControl
...
On Sunday, June 30, 2002, at 04:47 PM, Jeremy Dronfield wrote:
On Sunday, June 30, 2002, at 09:43 pm, email@hidden wrote:
1) You did tell IB to create an Instance of SRControls in your
MainMenu.nib right?
Yes.
If all you need is to get the app delegate somewhere else (like in
your awakeFromNib of somewhere else..
the [ NSApp delegate ] call will do that for you..
You can then store it in an instance var in your
SRBookmarkController ..
As in sRControls = [NSApp delegate] ? If so, I've tried it, and it
doesn't work. If not, could you tell me how it should be stated?
Is this document based btw? I.e. is this a document type w/ a class
who overrides NSDocument ??
No, it isn't. There has to be a simple and obvious answer to this
problem. Passing a variable from one class to another is such an
obvious thing to need to do, I must be missing something on a par
with "your computer won't work because you haven't pressed this
button here that says ON".
-J.
_______________________________________________
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.