我在NSURLConnection中遇到了一个问题。即
我已经创建了NSURLConnection的全局实例。
NSURLConnection *con;if (con){
[con release]];
con = nil;
}
con = [NSURLConnection initwithRequest: request delegate:self];这是处理内存问题的正确方法吗?因为有时候我的项目崩溃了(我想是因为它)。如果不是,那么什么才是处理内存问题的合适方法呢?
谢谢。
发布于 2013-06-28 23:26:02
您可以按如下方式使用NSURLConnection属性:
@property (nonatomic, readwrite, retain) NSURLConnection connection;您可以按如下方式启动连接:
self.connection =[[NSURLConnection alloc] initWithRequest:request
delegate:self
startImmediately:NO];
[self.connection scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes];
[self.connection start];在github上有一个例子。
https://stackoverflow.com/questions/16954145
复制相似问题