AFNetworking "message sent to deallocated instance"错误



因此,在我的项目中使用" afnetworking"时,我尝试了非常基本的示例只是为了确保其正常工作,但我一直遇到以下错误:

[NSConcreteMutableData appendData:]: message sent to deallocated instance 0x83aa8030

我的代码是:

    NSDictionary *params = @{@"username": username,
                             @"password": password,
                             @"comment_id": comment_id]};
    AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc]initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
    [manager POST:url parameters:params progress:nil success:^(NSURLSessionTask * _Nonnull task, id _Nullable responseObject) {
        NSLog(@"JSON: %@", responseObject);
    } failure:^(NSURLSessionTask * _Nullable operation, NSError * _Nonnull error) {
        NSLog(@"Error: %@", error);            
    }];

错误发生在以下函数中,该功能是脚本的一部分:([afurlsessionManagertaskDelegate urlsession:datatask:didreceivedata:] afurlsessionmanager.m:262)

#pragma mark - NSURLSessionDataDelegate
- (void)URLSession:(__unused NSURLSession *)session
      dataTask:(__unused NSURLSessionDataTask *)dataTask
didReceiveData:(NSData *)data{
self.downloadProgress.totalUnitCount = dataTask.countOfBytesExpectedToReceive;
self.downloadProgress.completedUnitCount = dataTask.countOfBytesReceived;
[self.mutableData appendData:data];}

尝试将AFHTTPSessionManager的实例作为属性存储在类中。类似:

@property (nonatomic, strong) AFHTTPSessionManager *manager;

那么,希望您不应该看到有关被交易的对象的错误!否则请发布更多有关该问题的上下文,以便我可以为您提供帮助。

相关内容

  • 没有找到相关文章

最新更新