On Sep 30, 2009, at 7:56 PM, Stephen J. Butler wrote:
On Wed, Sep 30, 2009 at 6:41 PM, David Hirsch <dhir...@mac.com> 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;
Recent versions of Xcode warn about this problem:
test.m: In function ‘main’:
test.m:15: warning: multiple methods named ‘-mode’ found
/System/Library/Frameworks/AppKit.framework/Headers/NSMatrix.h:
123: warning: using ‘-(NSMatrixMode)mode’
test.m:6: warning: also found ‘-(float)mode’
/System/Library/Frameworks/AppKit.framework/Headers/
NSColorPanel.h:97: warning: also found ‘-(NSColorPanelMode)mode’
You can make it work with:
float testmode2 = [(Phase*)[phases objectAtIndex:i] mode];
Another option is to rename your -mode method.
--
Greg Parker gpar...@apple.com Runtime Wrangler
_______________________________________________
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 arch...@mail-archive.com