• 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: observing dealloc
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: observing dealloc


  • Subject: Re: observing dealloc
  • From: James Bucanek <email@hidden>
  • Date: Tue, 29 May 2007 07:59:38 -0700

Ken Tozier <mailto:email@hidden> wrote (Tuesday, May 29, 2007 10:22 PM -0400):
The main reason is that with a generalized mechanism, there's no
possibility for static variable name collisions. Many different
classes could all have a "gFoo" global without having to dream up a
different name for each class.

Use static variables.

You could have fifty classes that all implement ...

    static id sFoo;     // really stupid name

    ...

    @implementation AnyClass

+ (void)initialize
{
// if (sFoo==nil) -- pointless test; initialize only runs once
sFoot = [[NSObject alloc] init];
}


    + (id)foo
    {
        return (sFoo);
    }

... and you would have no conflicts or confusion. The symbol name 'sFoo' is local to the scope of module and couldn't possibly conflict with any similarly named static in another module.

On the other hand, what you're proposed solution would simply replace global name collisions (which could be caught at link time) with key value collisions (which wouldn't be caught until run-time, if ever).

Personally, I think you're over engineering this problem.

--
James Bucanek

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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


  • Follow-Ups:
    • Re: observing dealloc
      • From: Wincent Colaiuta <email@hidden>
References: 
 >Re: observing dealloc (From: Ken Tozier <email@hidden>)

  • Prev by Date: Re: cocoa and ms windows
  • Next by Date: Re: observing dealloc
  • Previous by thread: Re: observing dealloc
  • Next by thread: Re: observing dealloc
  • Index(es):
    • Date
    • Thread