Incompatible pointer to integer conversion assigning to ‘NSUInteger’ (aka ‘unsigned int’) from ‘NSUInteger *’ (aka ‘unsigned int *’); dereference with *

Here’s an error that took longer than it should have to figure out:

Incompatible pointer to integer conversion assigning to ‘NSUInteger’ (aka ‘unsigned int’) from ‘NSUInteger *’ (aka ‘unsigned int *’); dereference with *

1. The Model (i.e. setCard) had this:

@property (nonatomic) NSUInteger number;

This is anĀ NSUInteger which does the job (calling it number is perhaps misleading as it’s an int rather than an NSNumber but it’s not breaking anything so let’s go with it).

2. The View (i.e. setCardView) had this:

@property (nonatomic) NSUIntegerĀ  number;

Also looks OK.

Checking the line that’s causing the problem (by clicking the yellow alert in Xcode) it turns out this was the root of the problem:

card.number = (NSUInteger *)[number intValue];

number was declared earlier as NSNumber *number

NSUInteger is a slightly weird beast. It’s NOT a class like NSNumber. It’s just an int that’s been typedef’d.

Way more information here: http://stackoverflow.com/questions/1172600/when-should-you-not-use-the-asterisk-when-declaring-a-variable-in-objective/1173452

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *