• 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: where have all the IVARS gone? (long time passing...)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: where have all the IVARS gone? (long time passing...)


  • Subject: Re: where have all the IVARS gone? (long time passing...)
  • From: email@hidden
  • Date: Mon, 10 Jul 2006 17:17:25 +1000

Is the scope of iVras are not limited to myClass?

No, it's not; declaring the same variable to be exactly the same type in multiple places is not an error. It doesn't even yield a compiler warning. But if you try giving them default values that are different, you'll then get a compiler error. And even if you think you've declared them in two different categories, even on separate objects, they both still refer to the same global variable.


So while it is true you don't get name conflicts with other global variables of the same name (at least, others also declared in separate categories), you're still creating globals, not instance variables, and they're not unique globals, either.

Back to the original point - if you want to hide data in a class, you need to realise you really can't; the runtime needs information to do it's work, and that information reveals an awful lot about your class. But there are ways to put it somewhat out of reach - class clusters with private concrete implementations is one popular approach. Other methods of obfuscation include using key-value coding (KVC) to store data - this also works nicely for categories, provided the class you're extending supports KVC.

Wade Tregaskis

    ICQ: 40056898
    AIM, Yahoo & Skype: wadetregaskis
    MSN: email@hidden
    iChat & email: email@hidden
    Jabber: email@hidden
    Google Talk: email@hidden

    http://homepage.mac.com/wadetregaskis/

-- Sed quis custodiet ipsos custodes?


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >RE: where have all the IVARS gone? (long time passing...) (From: Vinay Prabhu <email@hidden>)

  • Prev by Date: RE: where have all the IVARS gone? (long time passing...)
  • Next by Date: Re: where have all the IVARS gone? (long time passing...)
  • Previous by thread: Re: where have all the IVARS gone? (long time passing...)
  • Next by thread: Re: where have all the IVARS gone? (long time passing...)
  • Index(es):
    • Date
    • Thread