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 Build a Simple iPhone App (iOS7) Refactoring into a Model Readonly Attribute

ryanlee4
ryanlee4
1,984 Points

when the simulator is iPhone 4 inch with 64bit, the Xcode shows this error: implicit conversion loses integer precision

when the simulator is iPhone 4 inch with 64bit, the Xcode shows this error: implicit conversion loses integer precision : "NSUinteger"(aka ‘unsigned long’.),,,

it works with 32 bit ios system.

So is it there solution for generate random number within both 32 bit and 64 bit system ?

2 Answers

Stone Preston
Stone Preston
42,016 Points

if you post your code I could give you a more definitive answer of whats going on

its most likely just a warning, not an error. if you want to get rid of it try casting that integer to a 32 bit integer

(uint32_t)yourVariable

the arc4random_uniform function takes a 32 bit integer and returns a 32 bit integer. if you are on a 64 bit system you are probably passing it a 64 bit integer. try casting the argument to a 32 bit integer as shown above.

ryanlee4
ryanlee4
1,984 Points
-(NSString *) randomQuote{
    int random = arc4random_uniform( (uint32_t)self.quotes.count );
    return [self.quotes objectAtIndex:random];

} 

I did as you suggested . it works like a charm !

Thank you ! @Stone Preston