afnetworking-2

How do I get cached image stored by AFNetworking's UIImageView category?

廉价感情. 提交于 2019-12-12 04:16:40
问题 I'm using following category UIImageView+AFNetworking.h from AFNetworking in my app, its working fine, its caching photos for me and loads images smoothly. At one point, I want to get an image which is already there in my cache. So I dig up into above category class where I found following code, which I think – can be helpful. Here's the snippet from it: @implementation AFImageCache - (UIImage *)cachedImageForRequest:(NSURLRequest *)request { switch ([request cachePolicy]) { case

AFNetworking Domain=NSURLErrorDomain Code=-1001 “Request timeout"

我与影子孤独终老i 提交于 2019-12-12 03:20:02
问题 When I launch my app after some times the first request with cellular data not working, I have Domain=NSURLErrorDomain Code=-1001 (request Time out). All works fine in Wifi. When i retry with cellular data all works. Only the first request is not working. Thanks to help. 来源: https://stackoverflow.com/questions/28105388/afnetworking-domain-nsurlerrordomain-code-1001-request-timeout

Run request operations in loop inside operation

女生的网名这么多〃 提交于 2019-12-12 02:26:08
问题 How can I run multiple requests inside the success block of 1 request and wait for it to finish? [manager GET:url parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) { NSLog(@"%@ Response: \n%@", url, responseObject); resultsArray = [[NSMutableArray alloc] init]; for (NSDictionary *json in [responseObject objectForKey:@"items"]) { [self getDetails:json]; } } failure:^(AFHTTPRequestOperation *operation, NSError *error) { [SVProgressHUD dismiss]; }]; Where in

how to set the authorization token based on this curl?

馋奶兔 提交于 2019-12-12 02:25:49
问题 I want add a token for Authorisation to the header. Here it is the curl that my backend ask me to set before any interaction: curl -H 'Authorization: Token token="replace-with-token"' http://domain.com/topic here is my code: [config setHTTPAdditionalHeaders:@{@"Authorization":@"token=\"4959a0bc00a15e335fb6\""}]; I keep getting "HTTP Token: Access denied." does any one know reason? 回答1: I believe it would be this?: [config setHTTPAdditionalHeaders:@{@"Authorization":@"Token token=\

Wrapping blocks based API in convenience methods

你离开我真会死。 提交于 2019-12-11 23:13:56
问题 I'm using AFNetworking 2.0 to access a web api (although this would apply to NSURLSession as well), and currently I have a bunch of code that looks like this: [self.rottenTomatoesManager GET:@"movies.json" parameters:@{@"q" : searchString, @"apikey" : [self.rottenTomatoesManager apiKey]} success:^(NSURLSessionDataTask *task, id responseObject) { NSHTTPURLResponse *response = (NSHTTPURLResponse *)task.response; if(response.statusCode == 200){ NSDictionary *responseData = responseObject; self

Compile error after installing AFNetworking 2.0

夙愿已清 提交于 2019-12-11 21:28:31
问题 I just installled AFNetwokring 2.0 and first compiled it with a simulator, that working 100% and no errors were found. The test call i made also worked as it should. Then i tried compiling it for a real iPhone device, and now i receive this error, when trying to build: Ld /Users/sorendidriksen/Library/Developer/Xcode/DerivedData/GB_Mobil_DK-abwnrramdycsilhhfusihgjqvead/Build/Intermediates/GB\ Mobil\ DK.build/Debug-iphoneos/GB\ Mobil\ DK.build/Objects-normal/armv7/GB\ Mobil\ DK normal armv7 cd

How to check Internet is working or not in ios

让人想犯罪 __ 提交于 2019-12-11 19:33:57
问题 I am trying to detect the internet is working or not on the device using AFNetworking ; referred to the answer here on the SO AFNetworking 2.0 Reachability . I am able to detect device is connected with WiFi or 3G.. The problem is Actually internet is not working like the WIFI is on but internet is not working. How Can i detect internet is working .Like we check using ping.... I am checking using the following -(BOOL)connected { __block BOOL reachable; // Setting block doesn't means you area

HTTPMaximumConnectionsPerHost is ignored in AFHTTPSessionManager

拥有回忆 提交于 2019-12-11 12:42:39
问题 I am trying to use AFNetworking2.0 with new NSURLSession class to fetch some data. In particular I am interested in new HTTPMaximumConnectionsPerHost property of NSURLSessionConfiguration but unfortunately it doesn't seem to work as I expect. @interface ViewController () @property (nonatomic, strong) AFHTTPSessionManager *httpSessionManager; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; NSURLSessionConfiguration *sessionConfig = [[NSURLSessionConfiguration

AFHTTPSessionManager subclass swift

痞子三分冷 提交于 2019-12-11 12:26:05
问题 What is the correct way to create singletone subclass of AFHTTPSessionManager with custom session configuration? class DefaultSessionConfiguration: NSURLSessionConfiguration { override init () { super.init() self.HTTPShouldSetCookies = true HTTPCookieStorage?.cookieAcceptPolicy = NSHTTPCookieAcceptPolicy.Always HTTPAdditionalHeaders = [ "Content-Type": "application/json"]; } } let baseUrl = "https://google.com" class HTTPManager: AFHTTPSessionManager { static let _sharedAPIManager =

Receiving response using AFNetworking in Swift

痴心易碎 提交于 2019-12-11 12:05:49
问题 I am new to AFNetworking and I am trying to follow the tutorial of Raywenderlich on the same. So I have got this code for JSON parsing and I am struggling with converting that to Swift . I have tried many tutorials and StackOverflow answers but couldn't find a good explanatory one. - (IBAction)jsonTapped:(id)sender { // 1 NSString *string = [NSString stringWithFormat:@"%@weather.php?format=json", BaseURLString]; NSURL *url = [NSURL URLWithString:string]; NSURLRequest *request = [NSURLRequest