afnetworking

Accessing DailyMile API with AFNetworking 2.0

雨燕双飞 提交于 2019-12-25 02:09:46
问题 So I'm making a JSON request from an https site (after retrieving the auth token) and like a dozen other problems with AFNetworking on stack overflow, I'm getting this error: Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (JSON text did not start with array or object and option to allow fragments not set.) UserInfo=0x8dc2860 {NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.} The code I

AFNetworking restore progress bar after view reopened

自古美人都是妖i 提交于 2019-12-25 01:49:44
问题 within my app i have a UIViewController with a UIProgressView and a button to start a download with the AFNetworking library. How can i resume the download progress bar, after than the viewController is closed and then reopened? this is my code: ViewController.m [...] - (void) updateProgress:(float)progress forOperation:(AFHTTPRequestOperation *)operation { self.downloadprogress.progress = progress; } - (void)downloadTest:(NSString *)cid { NSString *string = [NSString stringWithFormat:@"%@get

Measuring response time in AFNetworking HTTP GET

烈酒焚心 提交于 2019-12-24 21:18:42
问题 I am trying to measure time taken per GET request when downloading a file using AFNetworking. I am downloading a file repeatedly in a loop. The problem I am having is that the way I am measuring total time, it gives a much larger total time than it actually is. For example, for 50 downloads it gives 72 sec but in reality it only took around 5 sec. I also suspect 5 sec is too low for 50 downloads(the download size is 581 kb per file). How do I effectively measure time in this case? I need time

AFNetworking: downloading files in queue

余生长醉 提交于 2019-12-24 20:16:13
问题 I just started using AFNetworking and so far it worked fine for just getting data from the web. But now I have a list of files that need to be downloaded to the device for(NSDictionary *issueDic in data) { Issue *issue = [[Issue alloc] init]; ... [self getOrDownloadCover:issue]; ... } getOrDownloadCover:issue checks if a file already exists locally, if it does, it just saves that path, if it doesn't, it downloads the file from a given url - (void)getOrDownloadCover:(Issue *)issue { NSLog(@

token is saved but unable to bypass the login page

不打扰是莪最后的温柔 提交于 2019-12-24 15:31:37
问题 I am trying to bypass the login page to welcome page if the person already have a token. I am using basic auth and afnetworking for the api call. Once the user logs the username&password, I base 64 the info and get a token. I save the token in a nsobject class where I create a token singleton and a simple is logged in method where it checks if the user has the token or not. But for some reason I always see the login page(meaning it skips my condition method). If any one can point out where I

AFNetworking - JSON: Receiving “numbers” instead of JSON

浪尽此生 提交于 2019-12-24 13:49:01
问题 I have set up an AFNetworking HTTP Client subclass and registered the HTTP operation as AFJSONRequestOperation. And set default headers like so: [self setDefaultHeader:@"Content-Type" value:@"application/json"]; [self setDefaultHeader:@"Accept" value:@"text/html"]; Then I am making a call to a RESTful server like so: [[TheAPIClient sharedClient] getPath:domain parameters:nil success:^(AFHTTPRequestOperation *operation, id JSON) { NSLog(@"%@", JSON); } failure:^(AFHTTPRequestOperation

Read status line (status code and reason phrase) using AFNetworking's AFHTTPRequestOperation

拟墨画扇 提交于 2019-12-24 10:56:57
问题 I am switching from ASIHTTPRequest to AFNetworking in an iOS application. RF2616 (HTTP/1.1) defines a "status-line" by the combination of "Status Code" and "Reason Phrase". Sometimes the server adds some specific information in this "Reason Phrase" and I found it rather handy that ASIHTTPRequest allowed me to access it easily via ASIHTTPRequest *request = ...; NSString *reason = request.responseStatusMessage; My problem is that I can't find any way to do it with AFHTTPRequestOperation

Image downloading progress bar not smooth using afnetworking in iOS

岁酱吖の 提交于 2019-12-24 10:01:08
问题 I am currently downloading the image using afnetworking, but the progress bar is not smooth in the first time, but when I run this code second time, the progress bar is smooth, here is my code to download images. progress bar works like go up, down than smooth, but when I run code the second time it works smooth progressBar.progress = 0.0; self.imageDownloads=[[NSMutableArray alloc]init]; [self.imageDownloads addObject:[[ImageDownload alloc] initWithURL:[NSURL URLWithString:@""]]; for (int i

Unable to get responses from local server when connecting via iOS device

谁说我不能喝 提交于 2019-12-24 08:39:35
问题 Im using AFNetworking to retrieve items from a basic rails server in a simple iOS project. When I make the request in the simulator, everything works smoothly. However, when I make the same request while running the project on my device, I'm getting a frustrating error. I understand that I cannot connect to localhost directly from my device and therefore need to use my ip address, which I am doing. This is the weird part: when I make a request to the server, I can see in my terminal that the

AFURLSessionManager when my ViewController was navigated app crashed

谁说我不能喝 提交于 2019-12-24 07:07:42
问题 I have problem in AFURLSessionManager for Objective-C iOS. I have 2 viewController and use AFURLSessionManager for getData from server. when user navigate to viewContoller2 that have AFURLSessionManager request and user has very bad network and press back button, AFURLSessionManager want to call delegate, crashed and show EXC_BAD_ACCESS(code=EXC_I386_GPFLT) when i navigate to a viewController, AFURLSessionManager task finish late and viewController was changed by user and AFURLSessionManager