我在()数据被使用之前释放与ASIHTTPRequest异步模式
NSURL *url = [NSURL URLWithString:@"http://somewebsite.com/data.txt"];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setDelegate:self];
[request startAsynchronous];
)从我的viewDidLoad中调用的函数这是我requestFinished(在那里我做了一些文本替换和填充使用ASIHTTPRequest异步模式一个NSArray与我从网站收到的数据。这只是文本,每行一个数据项。 viedDidLoad()中的NSArray(和alloc/init)。
- (void)requestFinished:(ASIHTTPRequest *)request
{
NSString *sTemp = [request responseString];
sTemp = [sTemp stringByReplacingOccurrencesOfString:@"\n" withString:@","];
arrayTidalData = [sTemp componentsSeparatedByString:@","];
NSLog(@"Loaded %d items into the array",[arrayTidalData count]);
[tableTideTimes reloadData];
}
NSLog报告127个数据项目。
现在,我使用NSArray数据填充UITableView。 但是,在的cellForRowAtIndexPath()当我尝试做一个计数访问的NSArray(arrayTidalData),例如,我得到如下:
TideTimes [14696:B303] * - [__ NSArrayM计数]:消息发送到释放实例0x4e6c6a0
(我打开NSZOMBIEEnabled = YES得到这个数据)
看来NSArray的已释放之前,我可以使用它。我也尝试用requestFinish()中的数据填充NSString,但获得了相同的结果。
我错过了一些非常简单的东西,还是我在做一些非常错误的事情?
(这是我第一次与ASIHTTPRequest)
谢谢,我没有想过添加保留。 太棒了! – FiddleMeRagged
不客气。 – Nekto