On May 18, 2008, at 10:22 PM, Andrew Farmer wrote:
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.
Although the last method -- with properties -- would be my favored approach on Leopard, the OP wanted to work with *mutable* arrays. There have been some threads on this in the past (available in the archives), but basically you have to specify, basically, either retain, assign, or copy for your properties -- mutableCopy is *not* available. This means that, should you wish to make a mutable copy when setting your property, you'll still have to create an accessor. That may or may not be a bad thing in this case, but it might not save any code.
Cheers, Andrew
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]