先看一下ARC:
NSMutableDictionary *datesDict = [[NSMutableDictionary alloc]init];
NSMutableArray *datesArray = [[NSMutableArray alloc]init];
for (NSString *key in programsArray) {
datesArray = [_onDemandDictionary objectForKey:key];
NSMutableArray *newDates = [[NSMutableArray alloc]init];
int count;
for (count = 0; count <datesArray.count; count++) {
NSMutableDictionary *programsDict = [[NSMutableDictionary alloc]init];
programsDict = [datesArray objectAtIndex:count];
[newDates addObject:[programsDict objectForKey:@"date"]];
}
[datesDict setObject:newDates forKey:key];
}
在運行解析工具的時候,出現這一句:**stored to (datesArray and programsDict) during its initialization is never read**
在這一句
NSMutableArray *datesArray = [[NSMutableArray alloc]init];
programsDict = [datesArray objectAtIndex:count];
為什麼?找不到原因和解決方法,請高人指點,謝謝!
問題出在你創建新的NSMutableArray
.然後在這一句
NSMutableArray *datesArray = [[NSMutableArray alloc]init];
把它分配給datesArray
,
但是接下來又把一個完全不同的值又分配給了datesArray
datesArray = [_onDemandDictionary objectForKey:key];
所以你最開始只要用這句就可以:
NSMutableArray *datesArray = nil;
和programsDict是一樣的