Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: Indexing expression is invalid because subscript type 'NSUInteger' is not an integral or objective c pointer type

I have an array named "rankStrings" and I am trying to get the data from it at an index as below...

NSArray *rankStrings = @[@"1", @"2", @"3", @"4", @"5", @"6", @"7", @"8", @"9", @"10"];

return [rankStrings[self.rank] stringByAppendingString:self.suit];

the "rank" is declared as...

@property (nonatomic) NSUInteger *rank;

I get error, "Indexing expression is invalid because subscript type 'NSUInteger' is not an integral or objective c pointer type".

I tried using "NSInteger" or "int" instead of "NSUInteger", but it is still the same.

Any help is much appreciated!!

like image 947
Ashish Priyadarshi Avatar asked Dec 16 '22 06:12

Ashish Priyadarshi


1 Answers

You are using a pointer to a NSUInteger, and the array expects a NSUInteger (primitive type) as index. Declare your property like this instead:

@property (nonatomic,assign) NSUInteger rank;
like image 77
Lucas Eduardo Avatar answered Feb 15 '23 23:02

Lucas Eduardo