0
我想用最新的AFNetworking版本2更新我的应用程序。从现在开始,他们改变了一些我想知道如何下载plist文件的东西。AFNetworking 2.0 Plist
我发现这个例子中的文档中:
NSURL *URL = [NSURL URLWithString:@"http://example.com/foo.json"];
NSURLRequest *request = [NSURLRequest requestWithURL:URL];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc]
initWithRequest:request];
operation.responseSerializer = [AFJSONSerializer serializer];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"%@", responseObject);
} failure:nil];
[operation start];
但我需要下载一个plist中我做了什么与AFNetworking 1这样的:
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://example.com/test.plist"] cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:10.0];
AFPropertyListRequestOperation *operation = [AFPropertyListRequestOperation propertyListRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id propertyList) {
NSDictionary *myTempDic = (NSDictionary *)propertyList;
myArray = [myTempDic objectForKey:@"Whatever"];
} failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id propertyList) {
//do something with the error
}];
[operation start];
我在哪里可以找到有关处理的任何实例与AFNetworking 2.0一起上榜?
我已经找到了这个方法。它是否正确?
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
operation.responseSerializer = [AFPropertyListResponseSerializer serializer];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id propertyList) {
NSDictionary *myTempDic = (NSDictionary *)propertyList;
myArray = [myTempDic objectForKey:@"Whatever"];
}failure:nil];
[operation start];