Re: Accessing variables across classes
Re: Accessing variables across classes
- Subject: Re: Accessing variables across classes
- From: Andrew Farmer <email@hidden>
- Date: Sun, 18 May 2008 22:22:58 -0700
On 18 May 08, at 22:06, Brett Powley wrote:
MyAppDelgate *ad = [NSApp delegate];
then do something with [ad myMutableArray]
Incorrect. You don't get accessors for instance variables
automatically like that.
To the original poster, there are three approaches you can go with here.
One is to set the variables as @public in the ApplicationDelegate,
then access them as applicationDelegate->theArray. This breaks
encapsulation, but it works.
Another approach is to write accessor methods on the
ApplicationDelegate to return the arrays and use those. This requires
some extra code.
Finally, if you're targeting Leopard, you can use properties. These
can be put together without any extra code, and they don't break OO
like @public variables do.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden