CJ.
CJ.

Reputation: 1044

Invalid receiver type 'NSUInteger'

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.

Upvotes: 0

Views: 1061

Answers (1)

Marcus S. Zarra
Marcus S. Zarra

Reputation: 46718

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.

Upvotes: 1

Related Questions