在AFNetworking异步块中调用函数

时间:2014-07-15 16:53:04

标签: ios function afnetworking

我的应用程序中有很多服务器请求,因此我尝试设置一个JasonParser类来处理我的AFNetworking请求。

这是我的功能:

- (void)startParseWithParameters:(NSDictionary*)incomingParameters andUrlAdress:(NSString*)urlAdress {
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    manager.responseSerializer = [AFJSONResponseSerializer serializer];

    NSDictionary *parameters = incomingParameters;
    __weak typeof(self) weakSelf = self;
    [manager POST:urlAdress parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {


         NSString *recivedErr = responseObject[@"error"];
        [weakSelf didReceiveResponse:[recivedErr integerValue];
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
         NSLog(@"Error: %@", error);
    }];
}

-(void)didReceiveResponse:(NSInteger)status {
}

但功能' didReceiveResponse'在块完成之前调用,因此我无法获得该值。 有办法处理吗?

0 个答案:

没有答案