객관적인 C 및 iPhone 프로그래밍에 익숙합니다. 이 코드를 실행할 때 셀이 채워지지 않는 이유를 알 수없는 것 같습니다. xml 내용이 콘솔 로그에 표시되고 xcode는 오류를 표시하지 않습니다. 어떤 도움을 줄 수 있습니까?UITableView : NSMutableArray가 테이블에 나타나지 않습니다.
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict
{
if(![elementName compare:@"Goal"]) {
tempElement = [[xmlGoal alloc] init];
} else if (![elementName compare:@"Title"]) {
currentAttribute = [NSMutableString string];
} else if (![elementName compare:@"Progress"]) {
currentAttribute = [NSMutableString string];
}
}
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{
if (![elementName compare:@"Goal"]) {
[xmlElementObjects addObject:tempElement];
} else if (![elementName compare:@"Title"]) {
NSLog(@"The Title of this event is %@", currentAttribute);
[tempElement setTitled:currentAttribute];
} else if (![elementName compare:@"Progress"]) {
NSLog(@"The Progress of this event is %@", currentAttribute);
[tempElement setProgressed:currentAttribute];
}
}
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
{
if (self.currentAttribute) {
[self.currentAttribute appendString:string];
}
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [xmlElementObjects count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [mtableview dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
}
// Set up the cell...
cell.textLabel.text = [xmlElementObjects objectAtIndex:indexPath.row];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
}
는 대답으로 자신의 질문에 회신하지 마십시오 (필자는 구문 분석 코드에서 제목 이름을 추측하고있어)보십시오. 대신 원래 게시물을 수정하십시오. –