Re: class keeps track of object
Re: class keeps track of object
- Subject: Re: class keeps track of object
- From: "Sherm Pendley" <email@hidden>
- Date: Tue, 1 Jul 2008 19:02:38 -0400
On Tue, Jul 1, 2008 at 6:49 PM, Jonathan Hess <email@hidden> wrote:
> Han Daniel -
>
> You can use a global variable just like you would in C:
Yes, but...
> static Foo *bar = nil;
That's not a global. Static vars are file scoped. :-)
In Foo.m:
Foo *globalFoo = nil;
In Foo.h, somewhere outside the class @interface:
extern Foo *globalFoo;
That said, I think you have the right idea, with a file-scoped static
var and a +sharedFoo method being the only way to get at it. I'm just
saying, that's not a global variable. :-)
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
_______________________________________________
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