【发布时间】:2012-10-14 17:27:21
【问题描述】:
我正在尝试实现一种解析方法以将 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] 之前或同时运行,因为我最终得到了一个包含一组空数组的多维数组,所以我需要做的是确保@987654324 @ 在[individualRowOfBlocks removeAllObjects] 之后运行有什么方法吗?
【问题讨论】:
-
你为什么不使用图书馆呢?
-
我在这里找不到任何关于如何在网上任何地方进行操作的建议或教程或答案,所以我一直在开发我不久前使用 GDataXMLNode 做的教程,然后解析它与此类似,这就是为什么...
标签: objective-c multidimensional-array xml-parsing nsmutablearray