【发布时间】:2011-06-10 13:35:53
【问题描述】:
我正在使用 ASIHttpRequest 从 xml 文件中接收数据。但是,在异步请求期间,只要我更改视图(使用导航控制器返回上一个视图),应用程序就会崩溃,并在 main.m 上显示 EXC_BAD_ACCESS
这只发生在发出请求时。
下面是我的代码:
-(void)ProcessXML{
//Set url from string to url
NSURL *theurl = [NSURL URLWithString:@"http://twitter.com/statuses/user_timeline/2smssupport.xml"];
asirequest = [ASIHTTPRequest requestWithURL:theurl];
[asirequest setDelegate:self];
[asirequest startAsynchronous];
}
- (void)requestFinished:(ASIHTTPRequest *)request
{
NSLog(@"Saving to Defaults");
NSData *responseData = [request responseData];
xmlSaved = responseData;
prefs = [NSUserDefaults standardUserDefaults];
[prefs setObject:responseData forKey:@"xmlDownload"];
rssParser = [[RssParser alloc] loadXMLbyURL:xmlSaved];
[self.tableView reloadData];
NSLog(@"%@",[prefs dataForKey:@"xmlDownload"]);
}
Process XML 方法触发请求,然后接收到的数据在 RequestFinished 中处理。
ASIHTTPRequest 一定有我遗漏的东西,但我不知道它是什么?
谢谢
【问题讨论】:
标签: iphone objective-c ios cocoa-touch ios4