我在使用 AFNetworking 时遇到问题。我的网络服务期望 NSString 类型的两个参数返回 YES 或 NO。我的代码是这个
AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:[NSURL URLWithString:@" http://webservice.com "]];
NSMutableURLRequest *request = [httpClient requestWithMethod:@"GET" path:path parameters:@{ @"password":@"password", @"username":@"username"} ]; AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc]initWithRequest:request]; operation.outputStream = [NSOutputStream outputStreamToFileAtPath:path append:NO]; [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { NSLog(@"success: %@", operation.responseString); } failure:^(AFHTTPRequestOperation *operation, NSError *error) { NSLog(@"error: %@", operation.responseString); } ]; NSLog(@"%@", operation.request); [operation start];
它没有写:
NSLog(@"success: %@", operation.responseString)
; 瓯
NSLog(@"错误:%@", operation.responseString);
也就是说,不会进入 blcok。
有什么建议吗?
问候