Set objectAtIndex to be the integer in an NSString?
I've got this:
if ([[currentPlayer rankicon] isEqualToString:@"0"]) {
self.casteImage.image = [casteImages objectAtIndex:0];
}
Which works. However, I have some 16 images to assign, and since the NSString and the index i开发者_StackOverflow中文版d are the same, I'd like to find a more efficient way to do this. I've also tried:
NSInteger i = [[currentPlayer rankicon] integerValue];
self.casteImage.image = [casteImages objectAtIndex:[i]];
But that doesn't work. Could be a bug elsewhere in my code(or some syntax error in the above), of course, but was wondering if I'm anywhere near the right track.
Remove []
around i
in the second line.
精彩评论