Graphics Programs Reference
In-Depth Information
currentString = [[NSMutableString alloc] init];
[self setTitle:currentString];
}
else if ([elementName isEqual:@"link"]) {
currentString = [[NSMutableString alloc] init];
[self setLink:currentString];
}
}
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)str
{
[currentString appendString:str];
}
- (void)parser:(NSXMLParser *)parser
didEndElement:(NSString *)elementName
namespaceURI:(NSString *)namespaceURI
qualifiedName:(NSString *)qName
{
currentString = nil;
if ([elementName isEqual:@"item"])
[parser setDelegate:parentParserDelegate];
}
@end
Build the application to check for syntax errors.
In RSSChannel.m , put RSSItem into the object tree. At the top of this file, make sure
to import the header for RSSItem .
#import "RSSItem.h"
@implementation RSSChannel
- (void)parser:(NSXMLParser *)parser
didStartElement:(NSString *)elementName
namespaceURI:(NSString *)namespaceURI
qualifiedName:(NSString *)qualifiedName
attributes:(NSDictionary *)attributeDict
{
if ([elementName isEqual:@"title"]) {
currentString = [[NSMutableString alloc] init];
[self setTitle:currentString];
}
else if ([elementName isEqual:@"description"]) {
currentString = [[NSMutableString alloc] init];
[self setInfoString:currentString];
}
else if ([elementName isEqual:@"item"]) {
// When we find an item, create an instance of RSSItem
RSSItem *entry = [[RSSItem alloc] init];
// Set up its parent as ourselves so we can regain control of the parser
[entry setParentParserDelegate:self];
// Turn the parser to the RSSItem
[parser setDelegate:entry];
// Add the item to our array and release our hold on it
Search WWH ::




Custom Search