我正在尝试实现一种解析方法以将 XML 文档转换为多维数组,但是它依赖于在将该数组添加到多维数组之后需要从数组中删除对象,如下所示:
while (k<blockRowArray.count){ //loops through all rows one by one
NSLog(@"current k is %i", k);
GDataXMLDocument *currentRow = (GDataXMLDocument *) [blockRowArray objectAtIndex:k];
NSArray *arrayOfBlocks = [currentRow nodesForXPath:@"b" error:nil];
j = 0;
while (j <arrayOfBlocks.count) {
NSLog(@"current j is %i",j);
GDataXMLElement *blockElement = (GDataXMLElement *) [arrayOfBlocks objectAtIndex:j];
NSNumber* blockValue = [NSNumber numberWithInt:[[blockElement stringValue] intValue]];
[individualRowOfBlocks addObject:blockValue];
j++;
}
k++;
NSLog (@"Current row of blocks array is %@",individualRowOfBlocks);
[rowBlocks addObject:individualRowOfBlocks];
[individualRowOfBlocks removeAllObjects];
}
然而[individualRowOfBlocks removeAllObjects]
,显然是在同一时间或之前运行,[rowBlocks addObject:individualRowOfBlocks]
因为我最终得到一个多维数组,其中包含一组空数组,所以我需要做的是确保[individualRowOfBlocks removeAllObjects]
在[individualRowOfBlocks removeAllObjects]
任何这样做的方法之后运行?