Re: Accessing variables across classes
Re: Accessing variables across classes
- Subject: Re: Accessing variables across classes
- From: Adam Leonard <email@hidden>
- Date: Sun, 18 May 2008 23:13:12 -0700
Hi,
What you are doing is probably bad design. I would recommend your read
up on the MVC (Model View Controller) pattern: http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaFundamentals/CocoaDesignPatterns/chapter_5_section_4.html
In your set up, the ApplicationDelegate is your controller, the
NSMutableArray's are your models, and your NSView's are obviously your
views.
What you probably want to do is add accessor methods or properties to
your NSView for these NSMutableArrays. For an example of these
accessors, see http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaViewsGuide/SubclassingNSView/chapter_6_section_5.html#/
/apple_ref/doc/uid/TP40002978-CH7-SW34
Then, in your ApplicationDelegate, you would just call [myView
setFoo:myMutableArray].
That way, ApplicationDelegate is fully fulfilling its role as a
controller: connecting your models (myMutableArray) to your view
(myView).
Adam Leonard
On May 18, 2008, at 10:03 PM, Joey None wrote:
Hello all,
I hope someone can help me with this.
I have my ApplicationDelegate which contains a couple of
NSMutableArrays with data in them.
Then I have a few CustomNSViews classes which I have sub-classed.
I need to access the NSMutableArrays declared on the AppDelegate
class from the NSView sub-classes I have created.
Any ideas on how to do this? I know there has to be a way and have
spent all night looking for it but so far no luck.
Thank you very much for all your help!
JC
_______________________________________________
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
_______________________________________________
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