Gab*_*iel 6 xml iphone rss xcode objective-c
我在为iPhone应用程序读取XML文件时出错.我的iPhone应用程序上有一个新功能,可以读取我的RSS源.一切看起来不错,但我有这个问题:
加载rss时出错.请检查您的Internet连接
这是我的代码:
- (BOOL) readRSS {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
[[NSURLCache sharedURLCache] setMemoryCapacity:0];
[[NSURLCache sharedURLCache] setDiskCapacity:0];
BOOL success = NO;
NSXMLParser *parser = nil;
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://rss.domain.com/%@.xml", self.currentPage]];
parser = [[NSXMLParser alloc] initWithContentsOfURL:url];
[parser setDelegate:self];
[parser setShouldProcessNamespaces:NO];
[parser setShouldReportNamespacePrefixes:NO];
[parser setShouldResolveExternalEntities:NO];
success = [parser parse];
[parser release];
[pool drain];
return success;
}
Run Code Online (Sandbox Code Playgroud)
然后我有这个代码:
- (void) cleartbl:(NSInteger)type {
[[[self rssParser] rssItems] removeAllObjects];
[_tableView reloadData];
if(type == 1) {
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"RSS Feed"
message:@"Error while loading rss. Please check your Internet connection."
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles: nil];
[alert show];
[alert release];
}
Run Code Online (Sandbox Code Playgroud)
然后我指定:
if([elementName isEqualToString:@"title"]){
self.currentItem.title = self.currentItemValue;
}
Run Code Online (Sandbox Code Playgroud)
我的问题是什么,我错过了什么?