我有以下声明:
//.h file:
NSMutableArray *dataArray;
NSMutableDictionary *item;
//.m file
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict{
currentElement = [elementName copy];
if ([elementName isEqualToString:@"table"]){
item = [[NSMutableDictionary alloc] init];
currentEid = [[NSMutableString alloc] init];
currentEname = [[NSMutableString alloc] init];
currentEurl = [[NSMutableString alloc] init];
}
//NSLog(@"didStartElement");
}
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName{
if ([elementName isEqualToString:@"table"]) {
// save values to an item, then store that item into the array...
[item setObject:currentEname forKey:@"ename"];
//NSLog(@"%@",item);
[self.dataArray addObject:[item copy]];
NSLog(@"%@",dataArray);
}
}
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string{
if ([currentElement isEqualToString:@"eid"]) {
[currentEid appendString:string];
} else if ([currentElement isEqualToString:@"ename"]) {
[currentEname appendString:string];
//NSLog(@"%@",currentEname);
} else if ([currentElement isEqualToString:@"eurl"]) {
[currentEurl appendString:string];
}
// NSLog(@"foundCharacters");
}
显示时我得到空值NSMutableArray(dataArray)
。我怎么能解决这个问题?或者,如果可以,请帮助我了解如何NSMutableDicitonary
在表格视图单元格中显示数据。