Reputation: 3504
My plan was to get the random members of the array, therefore, I tried the solution which, firstly, generate the random number:
NSUInteger rnd = arc4random_uniform([myArray count]);
However, I got the warning "Implicit conversion loses integer precision".
How too work around that warning? Is there another way to get the random value which won't cause any warnings? I prefer only code implementations, not through the settings as several answers to the similar questions suggest.
Upvotes: 0
Views: 134
Reputation: 2643
Just change the code to the following :
NSUInteger rnd = arc4random_uniform((uint32_t) [myArray count]);
The compiler gave the warning as on your machine, NSUInteger is a typedef of 64 bits, which may not be the case for other devices. Therefore, casting it, removes the warning.
Upvotes: 1