afnetworking

AFNetworking POST method call

帅比萌擦擦* 提交于 2019-12-11 21:21:41
问题 I am new to AFNetworking . How can i execute the success and failure blocks of the following NSMutableDictionary *rus = [[NSMutableDictionary alloc] init]; [rus setValue:@"1211" forKey:@"id"]; [rus setValue:@"33" forKey:@"man"]; [[AFHTTPRequestSerializer serializer] requestWithMethod:@"POST" URLString:@"http://mysite.co/service.php" rus]; How to show the success or failure after executing the above code fragment. 回答1: requestWithMethod does not actually complete the call, it just returns you

AFNetworking Trim Characters From Response

亡梦爱人 提交于 2019-12-11 19:26:22
问题 I am using AFNetworking to call a web service using basic auth. The issue is that I get FAILURE: Error Domain=NSCocoaErrorDomain Code=3840 "JSON text did not start with array or object and option to allow fragments not set." UserInfo={NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.} When I allow fragments, I get Invalid value around character 0 I spoke with our web developer and he is prefixing the JSON response with '//' for whatever

Download one file at a time using afnetworking

久未见 提交于 2019-12-11 19:16:10
问题 I have an array which contains different URLs. I want to download one file with a progress bar, than start the next one and so on. Here is my code that I have so far; -(void) func:(NSArray *) arry { NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; configuration.timeoutIntervalForRequest = 900; AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration]; NSMutableArray * downloadedUrl = [

How to reference a method of a class

心已入冬 提交于 2019-12-11 18:15:29
问题 I'm writing an App.net client and using ADNKit as the framework that communicates with the ADN's servers. I've gotten a few ideas from the open source code of Zephyr, an app.net client that was turned into an open source project. Their view controllers for displaying lists of posts (PostStreamViewController) use a data controlling object and a configuration object that has a property called apiCallMaker . The property is defined like this: typedef void (^APIPostListCallback)(NSArray *posts,

objective C QLPreviewController does not display image

梦想与她 提交于 2019-12-11 18:13:27
问题 i used Afnetworking to download image file, and display it using QlViewController. Here is my image: Here is my code to download and display image: NSURLSessionDownloadTask *downloadTask = [manager downloadTaskWithRequest:request progress:^(NSProgress * _Nonnull uploadProgress) { NSLog(@"NSProgress: %@", uploadProgress); // [SVProgressHUD showProgress:uploadProgress.fractionCompleted]; } destination:^NSURL *(NSURL *targetPath, NSURLResponse *response) { NSURL *documentsDirectoryURL = [

AFNetworking prefetch other images

a 夏天 提交于 2019-12-11 16:54:09
问题 I am using the UIImageView + AFNetworking category to download and display images from an array of URLs and populate a table view. Now I find that the other images are delayed because only the current cell's image will be loaded. I need to keep busy by fetching other images as well. My idea would be to write a for loop and start downloading and caching with AFNetworking, say, 10 other requests starting from current indexPath . Or should I just do the usual dispatch_async in the completion

didReceiveRemoteNotification: fetchCompletionHandler: download freezes

≯℡__Kan透↙ 提交于 2019-12-11 13:59:30
问题 Our app utilizes didReceiveRemoteNotification: fetchCompletionHandler: methods UIApplicationDelegate to start a download when a content-available push notification is received. The individual steps the app takes: [1] Receive a notification - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler { NSLog(@"Remote download push notification received");

Parsing http-multipart response

守給你的承諾、 提交于 2019-12-11 13:06:40
问题 I need receive http-multipart responses from web service. The multipart response with pairs of JSON and image. How to handle response in two parts (NSDictionary for JSON and NSData for image)? Thanks in advance! [UPDATE] I wrote a category for NSData. Code below: NSData+MultipartResponses.h #import <Foundation/Foundation.h> @interface NSData (MultipartResponses) - (NSArray *)multipartArray; - (NSDictionary *)multipartDictionary; @end NSData+MultipartResponses.m #import "NSData

AFNetworking Array returns JSON inside of block but not outside of block [duplicate]

≡放荡痞女 提交于 2019-12-11 12:06:28
问题 This question already has an answer here : AFJSONRequestOperation array populates but cannot NSLog contents outside of success block (1 answer) Closed 5 years ago . I've created a custom method that returns JSON data using the AFNetworking API. I'm trying to store data pulled from my web service in an Array as JSON. NSLog(@"%@", json); inside the block prints the JSON data to console. Outside the block NSLog(@"%@", json); return null. Why is this and how can it be fixed? What I'm trying to do

Uploading a file with POST using AFNetworking

試著忘記壹切 提交于 2019-12-11 11:53:30
问题 So I'm trying to upload an XML file to a server with POST using AFNetworking. So using example code from their site I have this set up. When it runs, something is uploaded to the server (or at least it leaves my computer). I can monitor the upload, when the upload is finished, the server recognizes that it completed and goes to load the file, but it loads an old XML. So its connecting properly to the server, but I'm not sure why the file upload isn’t working correctly. Also I just want to