iOS应用开发中AFNetworking库的常用HTTP操作方法小结

2020-01-15 15:35:15王振洲

    NSLog(@"Error: %@", error);
}];
[[NSOperationQueue mainQueue] addOperation:op];  
方法十一:Batch of Operations
复制代码
NSMutableArray *mutableOperations = [NSMutableArray array];
for (NSURL *fileURL in filesToUpload) {
    NSURLRequest *request = [[AFHTTPRequestSerializer serializer] multipartFormRequestWithMethod:@"POST" URLString:@"http://www.easck.com/>     NSLog(@"%lu of %lu complete", numberOfFinishedOperations, totalNumberOfOperations);
} completionBlock:^(NSArray *operations) {
    NSLog(@"All operations in batch complete");
}];
[[NSOperationQueue mainQueue] addOperations:operations waitUntilFinished:NO];


方法十二:获取请求的一些信息(我也没有用过,不太常用)
复制代码
Request Serialization

 

Request serializers create requests from URL strings, encoding parameters as either a query string or HTTP body.

NSString *URLString = @"http://www.easck.com/> URL Form Parameter Encoding

[[AFHTTPRequestSerializer serializer] requestWithMethod:@"POST" URLString:URLString parameters:parameters];

POST http://www.easck.com/
Content-Type: application/json

{"foo": "bar", "baz": [1,2,3]}



注:相关教程知识阅读请移步到IOS开发频道。