我遇到了字典timeStamps
将所有值更改为null
. 键都很好,即使我将键切换为值,反之亦然。无论顺序如何,值最终都为null
,而键最终完全按照应有的方式结束。
这是代码。它是一个 xml 解析器。它正在构建一个字典,其中包含一组键代码和一组值时间戳。键和值是表示类别的并行数组。
所有变量都在别处分配和启动。这将导入具有所有这些变量作为属性的头文件。@property (strong, nonatomic) Type variableName;
然后在主文件中有一行@synthesize variableName
. 此外,它具有variableName = [[Type alloc] init];
. 谢谢大家的帮助!
- (void) didStartElement (elementname is passed as xml tag)
{
//Tells us if we are in the dance categories
if ([elementName isEqualToString:@"categories"])
{
isCategory = YES; // Just tells us we're ready to start reading
}
else if ([elementName isEqualToString:@"category"] && isCategory)
{
onCategory = YES; //
}
}
- (void) foundCharacters (currentNodeContent is the info between tags)
{
currentNodeContent = (NSMutableString *) string;
}
- (void) didEndElement
{
// if leaving dance categories
if ([elementName isEqualToString:@"Category End"])
{
isCategory = NO; // We've left a category
}
else if ([elementName isEqualToString:@"code"] && onCategory)
{
Code = currentNodeContent;
currentNodeContent = nil;
isWaitingForTime = YES;
}
else if ([elementName isEqualToString:@"time"] && isWaitingForTime)
{
[runningList addObject:Code];
[runningList addObject:currentNodeContent];
isWaitingForTime = NO;
currentNodeContent = nil;
Code = @"";
}
else if ([elementName isEqualToString:@"dances"])
{
[timeStamps setObject:runningTimeList forKey:runningList];
[runningTimeList removeAllObjects];
[runningList removeAllObjects];
}
}