我的 NSMutableArray 充满了 Article(一个包含 NSString * 标题的自定义类)对象在一个方法中正确加载(在调试器中检查),但是当另一个方法被调用时,Article 对象似乎“忘记”了一些类变量(比如标题变量)。
下面是将 Article 对象加载到 NSMutableArray 中的代码:
for(int i=0;i<[articleURLs count];i++) {
Article * a = [[Article alloc] init];
[a initWithWebsite:[articleURLs objectAtIndex:i]];
if([sectionTitle isEqualToString:@"Features"]) [featuresArticles addObject:a];
if([sectionTitle isEqualToString:@"News"]) [newsArticles addObject:a];
if([sectionTitle isEqualToString:@"Sports"]) [sportsArticles addObject:a];
if([sectionTitle isEqualToString:@"Leisure"]) [leisureArticles addObject:a];
if([sectionTitle isEqualToString:@"Voices"]) [voicesArticles addObject:a];
if([sectionTitle isEqualToString:@"Editorial"]) [editorialArticles addObject:a];
if([sectionTitle isEqualToString:@"Page 13"]) [page13Articles addObject:a];
[a release];
}
这是另一种查找这些值的方法中的代码:
NSString *cellValue = @"ddd";
//NSArray * tempArray;
Article * a;
if([sectionTitle isEqualToString:@"Features"]) a = [featuresArticles objectAtIndex:indexPath.row];
if([sectionTitle isEqualToString:@"News"]) a = [newsArticles objectAtIndex:indexPath.row];
if([sectionTitle isEqualToString:@"Sports"]) a = [sportsArticles objectAtIndex:indexPath.row];
if([sectionTitle isEqualToString:@"Leisure"]) a = [leisureArticles objectAtIndex:indexPath.row];
if([sectionTitle isEqualToString:@"Voices"]) a = [voicesArticles objectAtIndex:indexPath.row];
if([sectionTitle isEqualToString:@"Editorial"]) a = [editorialArticles objectAtIndex:indexPath.row];
if([sectionTitle isEqualToString:@"Page 13"]) a = [page13Articles objectAtIndex:indexPath.row];
cellValue = [a getTitle];
我已经被困在这个问题上超过 24 小时了,互联网也没有帮助。有什么建议么?