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
Daniel Davies
2,105 PointsCrystalBall Warning when running on device.
Hey,
Finished the Crystal Ball app and when running it in the simulator no errors or warnings or anything - perfect.
When I run it on my iPhone Xcode throws out a warning. The app runs fine but the warning pops up.
The warning I'm getting is on the GWSCrystallBall.m where I call
- (NSString*) randomPrediction { int random = arc4random_uniform(self.predictions.count); return [self.predictions objectAtIndex:random]; }
The warning is:
Implicit conversion loses integer precision 'NSUInteger' (aka 'unassigned long') to 'uint_32_t' (aka 'unassigned int')
Not sure if there is any more to that warning as the screen crops it.
Any assistance would be appreciated.
3 Answers
Micah Elias
2,774 PointsChange the randomPrediction method to look like this:
- (NSString*) randomPrediction;
{
int random = arc4random_uniform((unsigned int)self.predictions.count);
return [self.predictions objectAtIndex:random];
}
Daniel Davies
2,105 PointsHey thanks, this works and removed the warning. Any ideas why this isn't provided on the videos?
Chris Shepherd
4,374 PointsWorked! Thanks Micah Elias, a quick explaination of why (unsigned int) needed to be added would be awesome :)
Update: So I had my iPhone Simulator on 4-inch 64-bit. I changed it back to 3.5-inch and the build worked without the (unsigned int).