Re: Damn sisters :-)
Re: Damn sisters :-)
- Subject: Re: Damn sisters :-)
- From: Brendan Younger <email@hidden>
- Date: Sun, 9 Dec 2001 14:15:25 -0500
On Sunday, December 9, 2001, at 04:45 AM, Riccardo Santato wrote:
I'm stuck into a very simple question but I can't manage how to get out:
getting values from "sister" classes.
watch out : I've said "sister" classes, not "sons" or "parent" ones,
so I
can't use any type of heredity...
In my application I've put a NSTextField and below an NSBrowser; the
intent is to make NSBrowser displays the directory contained into the
NSTextField.
Here are the steps I've done so far:
1) Designed the GUI (pretty obvious... :-)
2) Created an NSObject subclass for controlling the GUI ("General_GUI")
3) Created and instantiated a subclass of NSBrowser, wich works as a
delegate for the browser ("MyBrowser")
Now I just want "MyBrowser" class to read variables contained into the
"General_GUI" one. I've tried to include every .h file, to use the
@public statement but nothing... they are sister classes !
Damn sisters, they always get you mad ! :-)
How can I access the data contained into another sister class ?
Hoping I haven't bored you, I'm waiting for your help :-))
Thank you !
You are not supposed to have access to another class's data. Create
accessor methods to access the data. For instance,
- (id)myInstanceVariable
{
return myInstanceVariable;
}
And *then* use the data. However, just for future reference, you *can*
make a class instance into a C struct, see:
http://developer.apple.com/techpubs/macosx/Cocoa/ObjectiveC/4MoreObjC/Static_Options.
html. Pay attention to "Getting an Object Data Structure". Although,
really, you shouldn't be doing this.
Brendan Younger