【发布时间】:2011-07-31 08:51:11
【问题描述】:
我有一个视图控制器,它列出了UITableView 中的一些数据。为了下载数据,我使用 ASIHTTPRequest 我在另一个类中放置了哪些方法。
在我的视图控制器中,我设置了适当的委托来处理从ASIHTTPRequest 检索的数据。因此,从- viewDidLoad 的视图控制器中,我分配并初始化我的类,该类包含ASIHTTPRequest 方法,如下所示:
self.officesParser = [[[OfficesParser alloc] init] autorelease]; // retained property
然后在- viewDidAppear:我打电话给[officesParser downloadOffices];
我的- downloadOffices 方法如下所示:
- (void)downloadOffices {
// 1. Downloaded offices.json
NSURL *officesUrl = [NSURL URLWithString:@"http://example.com/example.json"];
ASIHTTPRequest *officesRequest = [ASIHTTPRequest requestWithURL:officesUrl];
// Always ask the server if there is new content available,
// If the request fails, use data from the cache even if it should have expired.
[officesRequest setCachePolicy:ASIAskServerIfModifiedCachePolicy|ASIFallbackToCacheIfLoadFailsCachePolicy];
// Store the cache permanently
[officesRequest setCacheStoragePolicy:ASICachePermanentlyCacheStoragePolicy];
[officesRequest setTag:1];
OfficesViewController *vc = [[OfficesViewController alloc] init];
[officesRequest setDelegate:vc];
[vc release];
[officesRequest startAsynchronous];
}
每次调用[officesParser downloadOffices] 方法后我都会得到:
*** -[OfficesViewController respondsToSelector:]: message sent to deallocated instance 0x6a2f6c0
我在这里做错了什么?
【问题讨论】:
标签: objective-c delegates uiviewcontroller