The general idea is to have the table property of the modified searchSuggestions array. In the parserDidStartDocument: method parserDidStartDocument: be sure to initialize it with a new, empty array - something like self.searchSuggestions = [NSMutableArray array]; .
Then, in the didStartElement delegate method, do this to get each suggested item.
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName attributes:(NSDictionary *)attributeDict { if ([elementName isEqualToString:@"suggestion"]) { NSString *suggestion = attributeDict[@"data"]; [self.searchSuggestions addObject:suggestion]; } }
Once you get the parserDidEndDocument: delegate parserDidEndDocument: be sure to do everything you need to do to display it - it depends on which object your parser delegate is. If the parser delegate is a table view controller, you can simply reload the table. If this is some kind of request object, you can call back the request delegate, execute the completion block or post a notification.
source share