开发者

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 iin the second line.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜