• 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: Accessor works intermittently
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Accessor works intermittently


  • Subject: Re: Accessor works intermittently
  • From: "Stephen J. Butler" <email@hidden>
  • Date: Wed, 30 Sep 2009 21:56:40 -0500

On Wed, Sep 30, 2009 at 6:41 PM, David Hirsch <email@hidden> wrote:
> I cannot figure out why this does not work:
>
>                Phase *thisPhase = [phases objectAtIndex:i];
>                float testmode = [thisPhase mode];
>                float testmode2 = [[phases objectAtIndex:i] mode];
>
> Following along with the code execution in the debugger, testmode gets the
> correct value, but testmode2 gets an erroneous value.  Note that phases is
> an NSMutableArray of Phase* and mode is a trivial accessor for a float
> stored inside Phase:
>
>                - (float) mode {return mode;}

Something else, probably in Cocoa, is defining a "mode" selector
before you do with a different return type. When ObjC can't determine
the exact signature of a selector (for example, because the instance
type is "id") it uses the first one it finds. Searching through the
header files, I see at least two candidates it's probably choosing:

./AppKit.framework/Versions/C/Headers/NSColorPanel.h:- (NSColorPanelMode)mode;
./AppKit.framework/Versions/C/Headers/NSMatrix.h:- (NSMatrixMode)mode;

You can make it work with:

float testmode2 = [(Phase*)[phases objectAtIndex:i] mode];
_______________________________________________

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

References: 
 >Accessor works intermittently (From: David Hirsch <email@hidden>)

  • Prev by Date: Re: NSDocumentController didCloseAllSelector
  • Next by Date: Re: NSDocumentController didCloseAllSelector
  • Previous by thread: Accessor works intermittently
  • Next by thread: error with movie player, iSightAudio.plugin
  • Index(es):
    • Date
    • Thread