【问题标题】:TWRequest leaking?TWRequest 泄露?
【发布时间】: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


【解决方案1】:

您需要将[TWRequest release]; 更改为[postRequest release];

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-06-02
    • 2015-12-17
    • 2015-03-10
    • 1970-01-01
    • 1970-01-01
    • 2012-04-04
    • 2012-07-03
    相关资源
    最近更新 更多