【发布时间】:2014-05-02 06:01:00
【问题描述】:
函数中的这一行会产生一个警告:PerformSelector 可能会导致内存泄漏,因为它的选择器是未知的。我做错了什么?
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
[_delegate1 performSelector:_selector1 withObject:json];
}
下面是performSelector方法
- (void)HttpRequest:(NSURL*)url PostString:(NSString *)poststring method:(int)method withselector:(SEL)selector withdelegate:(id)delegate
{
_responseData = [[NSMutableData alloc] init];
// procedures for parse at desired URL
request = [NSMutableURLRequest requestWithURL:url
cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData
timeoutInterval:5];
// set HTTP method
if (method == 0) {
[request setHTTPMethod:@"GET"];
// asks xml response
[request setValue:@"application/json" forHTTPHeaderField:@"Accept"]; }
_selector1 = selector ;
_delegate1 = delegate ;
[self startConnection];
return;
}
【问题讨论】:
标签: ios memory memory-leaks warnings