Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

'NSUInteger conversion loses integer' warning message in XCode

http://stackoverflow.com/questions/19372312/objective-c-implicit-conversion-loses-integer-precision-nsuinteger

I'm not sure how to remove this warning message. I found numerous questions on stackoverflow relating to the same warning message, however still really stuck here, any tips?

It's a warning attached to the predictionArray

- (IBAction)buttonPressed:(UIButton *)sender {

    //NSString *myString = @"It is decidely so";
    //self.predictionLabel.text = @"Definately yes";
    NSUInteger index = arc4random_uniform(predictionArray.count);

    self.predictionLabel.text = [predictionArray objectAtIndex:index];
}

3 Answers

Amit Bijlani
STAFF
Amit Bijlani
Treehouse Guest Teacher

Excellent explanation on StackOverflow!

Hey man I have the same issue, any solutions ?

Imgur

Amit Bijlani
Amit Bijlani
Treehouse Guest Teacher

Basically you need to convert the count. If you want an explanation then please see the link Leon posted above.

NSUInteger random = arc4random_uniform((uint32_t) self.predictions.count);

merci beaucoup !