afnetworking

setTaskDidReceiveAuthenticationChallengeBlock in AFNetworking 2.0

冷暖自知 提交于 2020-01-02 18:07:32
问题 Anybody know how to handle authentication in the 2.0 version of AFNetworking? I tried the below without success. The block is getting called (I had an NSLog in there) but the response is still a 401 error [self setTaskDidReceiveAuthenticationChallengeBlock:^NSURLSessionAuthChallengeDisposition(NSURLSession *session, NSURLSessionTask *task, NSURLAuthenticationChallenge *challenge, NSURLCredential *__autoreleasing *credential) { *credential = [[NSURLCredential alloc] initWithUser:username

setTaskDidReceiveAuthenticationChallengeBlock in AFNetworking 2.0

百般思念 提交于 2020-01-02 18:07:18
问题 Anybody know how to handle authentication in the 2.0 version of AFNetworking? I tried the below without success. The block is getting called (I had an NSLog in there) but the response is still a 401 error [self setTaskDidReceiveAuthenticationChallengeBlock:^NSURLSessionAuthChallengeDisposition(NSURLSession *session, NSURLSessionTask *task, NSURLAuthenticationChallenge *challenge, NSURLCredential *__autoreleasing *credential) { *credential = [[NSURLCredential alloc] initWithUser:username

AFNetworking 2.0 - mutable json

孤者浪人 提交于 2020-01-02 05:21:12
问题 My code currently looks like this NSURL *URL = [NSURL URLWithString:URLForSend]; NSURLRequest *request = [NSURLRequest requestWithURL:URL]; AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; operation.responseSerializer = [AFJSONResponseSerializer serializer]; [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { NSLog(@"%@", responseObject); [BoxJsonDataHelper gotNewJson:responseObject]; } failure:^

AFNetworking (AFHttpClient) offline mode not working with NSURLRequestReturnCacheDataDontLoad policy

左心房为你撑大大i 提交于 2020-01-02 02:21:08
问题 I am using AFNetworking in my app and try to make it work in the offline mode by use the cached data if available. I expected after I set the request cache policy to NSURLRequestReturnCacheDataDontLoad, getPath:parameters:success:failure: will success with the cached data while offline. However, even if there are data in the cache (I verified by check the cache with the code), getPath will simply fail in airplane mode. There was a thread in AFNetworking github: https://github.com/AFNetworking

Parsing an XML file with AFNetworking

℡╲_俬逩灬. 提交于 2020-01-01 19:30:16
问题 I am making a little weather app using the Yahoo api. This api gives me an XML file back. My problem is now how I can parse this file ? Here is my code that I have so far. AFXMLRequestOperation *operation = [AFXMLRequestOperation XMLParserRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, NSXMLParser *XMLParser) { NSLog(@"success"); XMLParser.delegate = self; [XMLParser parse]; NSLog(@"xmlParser is %@",XMLParser); } failure:^(NSURLRequest

iOS - Passing blocks to functions

人盡茶涼 提交于 2020-01-01 15:56:13
问题 I have a method call (it's a call from AFNetworking): AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) { NSLog(@"IP Address: %@", [JSON valueForKeyPath:@"origin"]); } failure:^(NSURLRequest *request , NSURLResponse *response , NSError *error , id JSON) { NSLog(@"Failed: %@",[error localizedDescription]); }]; and I'm trying to pull the sucess and failure blocks out into a

Error with AFNetworking for JSON Parsing

让人想犯罪 __ 提交于 2020-01-01 14:23:07
问题 I have the following code for JSON Parsing: NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"https://www.dropbox.com/s/qz16qyi3julygl9/facebook.json"]]; AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) { NSLog(@"Request Success %@",[JSON class]); } failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON) { NSLog(@

How to assign a .cer file in AFNetworking?

≡放荡痞女 提交于 2020-01-01 05:19:29
问题 I am using AFNetworking to develop iPhone application that establish HTTPS connections ,I want use self-signed cert or trusted cert I can define ,but I cannot find any function(API) in AFNetworking can do this. And I saw this page : How to use NSURLConnection to connect with SSL for an untrusted cert? .But I want to know how to assign a cer file? Thanks. 回答1: Well, just to be simple, follow this steps Copy your .cer file to your project bundle Assuming you are using AFHTTPRequestOperation

How To Clear Image cache or any cache in AFNetworking?

跟風遠走 提交于 2019-12-31 22:20:49
问题 Hi All can any one help me out how to clear the cache in AFNetworking. I used to have old version of AFNetworking and i see that it has been updated, Can any body help me out how to clean the cache for AFnetworking. Previously it was something like this SDImageCache *imageCache = [SDImageCache sharedImageCache]; [imageCache clearMemory]; [imageCache clearDisk]; [imageCache cleanDisk]; 回答1: If you're using AFNetworking, I recently implemented a little workaround to remove the image from the

How To Clear Image cache or any cache in AFNetworking?

旧时模样 提交于 2019-12-31 22:20:34
问题 Hi All can any one help me out how to clear the cache in AFNetworking. I used to have old version of AFNetworking and i see that it has been updated, Can any body help me out how to clean the cache for AFnetworking. Previously it was something like this SDImageCache *imageCache = [SDImageCache sharedImageCache]; [imageCache clearMemory]; [imageCache clearDisk]; [imageCache cleanDisk]; 回答1: If you're using AFNetworking, I recently implemented a little workaround to remove the image from the