Im making a simple NSArray, then getting a random Index from that array and storing it as an int, however im getting a warning saying it should be a long int, even though im only expecting it to return 0, 1 or 2. Not that its an issue, but i cant understand why.
NSArray *randomWordList = [NSArray arrayWithObjects:@"Hello", @"Test", @"Send", nil];
int randomWordIndex = rand() % [randomWordList count];`
NSArray’s
countmethod returnsNSUIntegerwhich is aunsigned longfor 64-bit builds. The reason the compiler is warning you is becauseintholds a smaller range of numbers thanlong, so it is warning you of potential loss of data.Just change
int randomWordIndextoNSUInteger randomWordIndex.