Hamdi-Lachaal
Hamdi-Lachaal

Reputation: 151

pointer to integer

I have an array of integer and i'm trying to get an element from the array; xcode keeps showing this message: "initialization makes integer from pointer without a cast"

I know that this warning means that i can't alloc integer to pointer type, and i'm asking how ca i get that element, or if there is a solution to convert pointer to integer

Here is my code:

NSString *pathvalidrep = [[NSBundle mainBundle] pathForResource:@"validrep" ofType:@"plist"];   
NSArray *tabreponses = [[NSArray arrayWithContentsOfFile:pathvalidrep] retain]; 
truerep = tabreponses;
[tabreponses release];

NSUInteger val1 = [truerep objectAtIndex:0]; //the warning apears here

thanx for help :)

Upvotes: 0

Views: 244

Answers (1)

user971401
user971401

Reputation:

Elements of the array are probably NSNumber objects... And the warning is appearing because of this, you assign a pointer to NSNumber to a NSUInteger.

Try :

NSUInteger val1 = [[truerep objectAtIndex:0] integerValue];

Upvotes: 2

Related Questions