开发者

Initialization makes integer without a cast

I get this warning and I am not sure how to fix it. The line where I get the warning is

NSInteger thescore = [[myDictionary objectForKey:@"Score"] objectAtIndex:0];

If it makes a difference, myDictionary is a NSDictionary

Edit: How is this? Btw my array is a NSMutableArray and not a NSArray

NSInteger thescore = [[myDictionary valueForKey:@"Score"] integerValue];

Edit 2: @Bavarious mentioned that I should do the following:

int thescore = [[myDictionary objectForKey:@"Scor开发者_运维知识库e"] integerValue];


The result of call [someArray objectAtIndex:0] is an object. And NSInteger is a primitive type:

typedef long NSInteger;

(cmd + double-click on NSInteger in xcode to see the definition)

I guess you might actually be storing NSNumber objects in your array. In this case, you could do

NSNumber *thescore = [someArray objectAtIndex:0];
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜