• 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: subclass overwriting superclass ivar
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: subclass overwriting superclass ivar


  • Subject: Re: subclass overwriting superclass ivar
  • From: Roland King <email@hidden>
  • Date: Wed, 26 May 2010 21:00:49 +0800

@interface A(MyCategory)

-(void)someMethodWhichLegallyAccessesThePrivateVariablePriv;

@end

That's legal, I can write a category against an already-compiled class without having the source and without recompiling it and I can access any of the private variables of that class. So no the compiler cannot throw away instance variables when it compiles the class originally even if no method of A used them originally because someone might go write a category against the compiled object which needs it later.

I'm sure there are other, much simpler reasons.



On 26-May-2010, at 8:41 PM, vincent habchi wrote:

> Le 26 mai 2010 à 14:22, Graham Cox a écrit :
>
>> I'm pretty sure you are mistaken. If this were even remotely true, object programming would be impossible.
>>
>> @private only declares the visibility of an ivar to its subclasses, it does not give the compiler carte blanche to write over anything it fancies.
>
> Hmmm... Let's say you have a class A with a private variable "priv" and b a pointer to a subclass of A. Is:
>
> [(A *)b priv]
>
> legal?
>
> Now, admitting B never accesses any of A variables, can the compiler optimize space by throwing away all A private variables?
>
> Vincent
>
> PS: thanks for this "carte blanche" :)_______________________________________________
>
> 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

_______________________________________________

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

  • Follow-Ups:
    • Re: subclass overwriting superclass ivar
      • From: Kyle Sluder <email@hidden>
    • Re: subclass overwriting superclass ivar
      • From: Jean-Daniel Dupas <email@hidden>
References: 
 >subclass overwriting superclass ivar (From: "email@hidden" <email@hidden>)
 >Re: subclass overwriting superclass ivar (From: vincent habchi <email@hidden>)
 >Re: subclass overwriting superclass ivar (From: Graham Cox <email@hidden>)
 >Re: subclass overwriting superclass ivar (From: vincent habchi <email@hidden>)

  • Prev by Date: Re: subclass overwriting superclass ivar
  • Next by Date: Re: subclass overwriting superclass ivar
  • Previous by thread: Re: subclass overwriting superclass ivar
  • Next by thread: Re: subclass overwriting superclass ivar
  • Index(es):
    • Date
    • Thread