• 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: Strange property/synthesized accessor behaviour
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Strange property/synthesized accessor behaviour


  • Subject: Re: Strange property/synthesized accessor behaviour
  • From: "Stephen J. Butler" <email@hidden>
  • Date: Sun, 10 Apr 2011 03:00:28 -0500

On Sat, Apr 9, 2011 at 9:52 AM, Philipp Leusmann <email@hidden> wrote:
> Who can explain this behavior to me? Why is oWidth != object.mWidth ? How can that happen?

It's an artifact of how Objective-C searches for selector
implementations. You're calling @selector(width) on an "id", and of
course "id" doesn't implement @selector(width).

So what Objective-C does is search for the first implementation of
@selector(width) that it finds. My guess is it finds the one in AppKit
first (greping the frameworks):

NSTableColumn.h:- (CGFloat)width;

Then when the compiler sets up the call site it does it expecting a
CGFloat return and that is handled differently than an integer. So the
call site and the implementation of how your width is done disagree
and you get some strange heisenvalue back.

When you cast the variable to "Result*", Objective-C now knows to use
YOUR implementation of @selector(width) and it sets up the call site
properly.
_______________________________________________

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: Strange property/synthesized accessor behaviour
      • From: Philipp Leusmann <email@hidden>
References: 
 >Strange property/synthesized accessor behaviour (From: Philipp Leusmann <email@hidden>)

  • Prev by Date: RE: Strange property/synthesized accessor behaviour
  • Next by Date: Re: How To Increment CALayer Retain Count?
  • Previous by thread: RE: Strange property/synthesized accessor behaviour
  • Next by thread: Re: Strange property/synthesized accessor behaviour
  • Index(es):
    • Date
    • Thread