【发布时间】:2011-11-08 17:58:36
【问题描述】:
我在 ios5 中使用 TWRequest,但 Leaks 报告了 TWRequest 的内存泄漏。
我正在做这样的事情,我是不是哪里出错了?
TWRequest *postRequest = [[TWRequest alloc] initWithURL:[NSURL URLWithString:@"http://api.twitter.com/1/friendships/create.json"] parameters:[NSDictionary dictionaryWithObject:@"auser" forKey:@"screen_name"] requestMethod:TWRequestMethodPOST];
// Set the account used to post the tweet.
[postRequest setAccount:twitterAccount];
// Perform the request created above and create a handler block to handle the response.
[postRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
NSString *output = [NSString stringWithFormat:@"HTTP response status: %i", [urlResponse statusCode]];
[TWRequest release];
}];
【问题讨论】:
-
我很惊讶这个作品:[TWRequest release]; Leaks 是否会告诉您哪条线路在泄漏?
-
任何可以发送到
NSObject实例的消息,您也可以发送到类。[TWRequest release];除了“工作”之外什么都不会做。 -
在Xcode中运行Analyze,可能会报错。
标签: iphone objective-c ios5