• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: class keeps track of object
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >class keeps track of object (From: Daniel Richman <email@hidden>)
 >Re: class keeps track of object (From: Jonathan Hess <email@hidden>)

  • Prev by Date: Re: Getting mouse moved events on overlay windows
  • Next by Date: Re: KVO Bug With Keypaths
  • Previous by thread: Re: class keeps track of object [solved]
  • Next by thread: Re: class keeps track of object
  • Index(es):
    • Date
    • Thread