我想使用此代碼我UIImage
從web服務添加到我的NSMutableArray:如何的UIImage添加到NSMutableArray的
for (int i=0; i<[totalRowCountString intValue]; i++)
{
NSString *criticsRatingString = [[JSON valueForKeyPath:@"movies.ratings.critics_rating"] componentsJoinedByString:@" "];
NSLog(@"criticsRatingString: %@", criticsRatingString);
if ([criticsRatingString isEqualToString:@"Certified Fresh"])
{
self.ratingImage = [UIImage imageNamed:@"rt_certified_fresh.png"];
}
else if ([criticsRatingString isEqualToString:@"Fresh"])
{
self.ratingImage = [UIImage imageNamed:@"rt_fresh.png"];
}
else if ([criticsRatingString isEqualToString:@"Rotten"])
{
self.ratingImage = [UIImage imageNamed:@"rt_rotten.png"];
}
else if ([criticsRatingString isEqualToString:@"Spilled"])
{
self.ratingImage = [UIImage imageNamed:@"rt_spilled.png"];
}
else if ([criticsRatingString isEqualToString:@"Upright"])
{
self.ratingImage = [UIImage imageNamed:@"rt_upright.png"];
}
[tomatorRatingImages addObject:self.ratingImage];
NSLog(@"tomatoRatingImages: %@", tomatorRatingImages);
}
但我的NSLog爲tomatoRatingImages返回NULL。任何想法爲什麼它返回NULL?
更新:我的NSMutableArray已經在我的viewWillAppear方法中初始化。
它已在我的viewWillAppear方法中初始化。 – jaytrixz 2013-02-14 03:11:43
沒關係。我找到了答案。在我的viewWillAppear的某處出現了一個錯字錯誤,我沒有正確初始化它。感謝endy指出它。 – jaytrixz 2013-02-14 03:14:47