views:

370

answers:

1

I have a Core Data entity whose header file looks like this:

@interface MyEntity : NSManagedObject
{
}

@property (nonatomic, retain) NSNumber * index;

@end

And it's implementation file looks like this:

@implementation MyEntity

@dynamic index;

@end

Now, I have a piece of code that looks like this:

NSArray* selectedObects = [myEntityArrayController selectedObjects];
NSUInteger theIndex = [[[selectedObects objectAtIndex:0] index] unsignedIntegerValue];

The 'myEntityArrayController' object is a NSArrayController which manages all entities of MyEntity. This code executes correctly, however XCode always gives the warning "Invalid receiver type 'NSUInteger'" for the last line of code. For some reason, XCode thinks that the index method returns a NSUInteger. I'm not sure why it thinks this, because 'objectAtIndex' returns an object of type 'id'.

I've cleaned the project several times, and these warnings have hung around for a while. Any suggestions are appreciated.

A: 

Unroll your code so that each message is on its own line and then walk through it with the debugger to make sure every object is what you think it is.

Marcus S. Zarra

related questions