我如何将此ASIFormDataRequest转换为AFNetworking?

时间:2015-03-10 08:21:42

标签: ios objective-c xcode

这是我用于ASIHTTPRequest的代码我想将其转换为AFNetworking

NSURL *url = [NSURL URLWithString:path];
                ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
                [request setRequestMethod:@"POST"];
                [request addPostValue:self.theNewJob.jobID forKey:@"form[job_id]"];
                [request addPostValue:thisJTF.typeFieldID forKey:@"form[jtf_id]"];
                [request setFile:fullPath forKey:@"form[userfile]"];
                [request startSynchronous];
                NSError *error = [request error];
                if (!error) {
                    NSString *response = [request responseString];
                    if ([response isEqualToString:@"SUCCESS"]) {
                        // debugger
                        NSLog(@"signature file uploaded");
                    } else {
                        // debugger
                        NSLog(@"signature file upload Fail: %@ response: %@", error, response);
                    }
                }

1 个答案:

答案 0 :(得分:0)

您需要手动替换所有方法。我找了它,我认为下面的链接很好开始:http://door3.com/insights/ios-programming-converting-asihttprequest-afnetworking