• 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: Objective-C Instance Variable Names
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Objective-C Instance Variable Names


  • Subject: Re: Objective-C Instance Variable Names
  • From: Richard Somers <email@hidden>
  • Date: Sat, 5 Apr 2008 21:20:42 -0600


On Apr 3, 2008, at 10:45AM, Jens Alfke wrote:

Properties and ivars are not the same thing. Properties are shorthand for methods, not variables. A property doesn't have to correspond to any instance variable, or to one with the identical name.

Excellent point. I did not realize that.

Often when I feel short on knowledge and experience on a particular topic I will look and see what Apple has done.

In reviewing CALayer.h again I noticed that this class has a ton of properties (frame, bounds, position, zPosition, anchorPoint, transform, sublayerTransform, contents, contentsRect, opaque, contentsGravity, opacity, hidden, masksToBounds, etc.) but no explicitly associated ivars that are visible.

The header looks like this.

    @interface CALayer : NSObject <NSCoding, CAMediaTiming> {
    @private
        struct _CALayerIvars {
            int32_t refcount;
            uint32_t flags;
            uintptr_t parent;
            CFMutableArrayRef sublayers;
            CALayer *mask;
            struct _CALayerState *state;
            struct _CALayerState *previous_state;
            struct _CALayerAnimation *animations;
            struct _CALayerTransaction *slots[3];
    #if defined (__LP64__) && __LP64__
            uint32_t reserved;
    #endif
        } _attr;
    }

So perhaps any ivar which may be associated with a property are hidden in "struct _CALayerState *state". If that is the case they why did they hide some of the ivars but not all of them?

I have also been looking through the WebKit framework and noticed that they will hide ALL of the instance variables in another class like this.

    @interface WebView : NSView {
    @private
        WebViewPrivate *_private;
    }

Can anyone shed light on this practice of hiding ivars? Is it mainly something that is being done by the framework developers and generally is not applicable to application developers? Why does Apple do this?

Regards,
Richard

_______________________________________________

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: Objective-C Instance Variable Names
      • From: Jim Puls <email@hidden>
References: 
 >Objective-C Instance Variable Names (From: Richard Somers <email@hidden>)
 >Re: Objective-C Instance Variable Names (From: Jens Alfke <email@hidden>)

  • Prev by Date: Re: How to create process independent of current process AND that takes command line arguments?
  • Next by Date: Re: Objective-C Instance Variable Names
  • Previous by thread: Re: Objective-C Instance Variable Names
  • Next by thread: Re: Objective-C Instance Variable Names
  • Index(es):
    • Date
    • Thread