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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to