2

我有一个简单的应用程序,它使用标准的 NSURLConnection 从网页访问 cookie。该应用程序的现有版本运行良好(为 3.0 开发),但是,我已经修改了该应用程序(使其完全兼容 iOS4),现在我在日志中收到以下警告:

CFHTTPCookieGetCreateDate 在此 OS 版本中已弃用。客户端必须调用 CFHTTPCookieGetCreationTime 或等效的 NS,否则有泄漏的风险。

该应用程序仍然可以正常工作,但我担心“泄漏”,有什么想法吗???我在我的应用程序中找不到“CFHTTPCookieGetCreateDate”!

我认为问题发生在:

- (void) connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
self.responseData = [NSMutableData data];

// information returned from the cookie
NSDictionary *headerFields = [(NSHTTPURLResponse*)response allHeaderFields]; 
NSURL *url = [NSURL URLWithString:urlString];

//Cookies Array 
cookies = [NSHTTPCookie cookiesWithResponseHeaderFields:headerFields forURL:url];

headerPointsTotal = [[NSString alloc] initWithFormat:@"%@", [cookies objectAtIndex:2]];

}

谢谢,

4

1 回答 1

1

不推荐使用仅意味着您应该小心使用它。这意味着在以后的 iOS 版本中,这个方法可能会被删除,然后你就会崩溃。

只是为了感兴趣,您可以将部署目标设置为 4.0 并查看是否再次出现。否则(如果这与您的代码无关)您可以忽略它。

于 2011-04-08T16:35:37.023 回答