views:

66

answers:

2

I'm really scratching my head on this one:

I have an object (MyObject) which I instantiate, and this object has an NSArray member variable.

The following simple code working in the sim:

MyObject *myObj = [[MyObject alloc] init];
NSArray *arr = [myObj myMemberArray];

When I hover over myObj in XCode the tooltip reads "MyObject". Good! But when I debug it on the device (OS 3.1.3) I get: "[NSCFArray myMemberArray]: unrecognized selector sent to instance ... " When I hover over myObj, sure enough it reads "NSCFArray".

Can anyone give me some pointers on where to go next with this? Thanks.

A: 

Is myMemberArray defined anywhere in MyObject?

-(void)myMemberArray { } in MyObject

Jordan
+1  A: 

How does it work in the sim and not on the device?

Probably on the sim, self just happens to have been left in the register which is used to return values, possibly from when you called self = [super init]; The iPhone has a different processor architecture and the machine code generated happens to have left the array in the register used to return the value, not self.

In your compiler warnings settings you should always set -Wall in other warnings flags. You should also enable the static analyzer setting (I forget where it is - it's somewhere in the target build settings). Both of these settings would allow you to detect this issue at compile time.

JeremyP