我错过了什么吗?因为我希望应用程序接收响应并做一些事情,即使它在后台.这是我在我的应用中使用的内容:
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
NSDictionary *parameters = /*generate the parameters*/;
NSURL *filePath = [NSURL fileURLWithPath:@"imageName.png"];
[manager POST:@"http://example.com/resources.json" parameters:parameters constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
[formData appendPartWithFileURL:filePath name:@"image" error:nil];
} success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"Success: %@", responseObject);
//debug here
//Told the app to stop the Loading View, save response to DB
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
//debug here
//Told the app to stop the Loading View and try again sometimes
}];
Run Code Online (Sandbox Code Playgroud)