【发布时间】:2009-11-12 03:32:40
【问题描述】:
我正在尝试从内存泄漏中清理我的代码,但我遇到了“释放”方法的问题。
这是我的代码:
NSArray *dict = [[NSArray alloc] initWithContentsOfURL:url];
if (dict == nil) {
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Error"
message:@"Cannot retrieve content. Please try again later."
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
[alert release];
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
return;
}
self.schedule = dict;
[dict release];
[url release]; //I receive a runtime error here, "BAD ACCESS"
我不明白为什么当我在 [dict release] 上面的行没有遇到同样的问题时;
【问题讨论】:
-
贴出显示 URL 分配方式的代码?
标签: iphone memory-leaks