afnetworking-2

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

What is the AFNetworking 2 equivalent to ASIHTTPRequest setMaxConcurrentOperationCount

∥☆過路亽.° 提交于 2019-12-25 01:54:14
问题 I was trying to limit the max connections but couldn't find the method. Does anyone know how to do this? 回答1: Probably what you want to do is to set a custom NSURLSessionConfiguration by creating your own AFURLSessionManager with initWithSessionConfiguration: . The session configuration allows you to set HTTPMaximumConnectionsPerHost . If you're using AFHTTPRequestOperationManager then you can get its operationQueue and set maxConcurrentOperationCount on it. 来源: https://stackoverflow.com

How to sign up through Rest API using AFNetworking 2.0?

和自甴很熟 提交于 2019-12-24 17:48:55
问题 I have to make parameter like this array( ‘token’, ‘data’ => array( ‘name’, ‘email’, ‘password’, ) ) As I am a beginner to use REST API service. So I can't able to make this. I tried the following way to request AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; NSDictionary *params = @{@"name" : name, @"email" : email, @"password" : password}; [manager POST:BASE_URL parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) { NSLog(@"JSON

AFNetworking GET parameters with JSON (NSDictionary) string contained in URL key parameter

烈酒焚心 提交于 2019-12-24 16:46:24
问题 This JSON string has to be sent: { "dashboard": "compact", "theme": "dark", "show_side_bar": "yes" } to a REST API using GET method in this format (since server retrieves data with this PHP code $_GET["setting"] ) with AFHTTPRequestOperationManager , such that the equivalent URL becomes: http://www.examplesite.com/api/change_setting?setting={ "dashboard" : "compact", "theme" : "dark", "show_side_bar" : "yes" } When I create an NSDictionary of parameters in AFHTTPRequestOperationManager 's GET

Posting image with Swift 2 + AFNetworking

99封情书 提交于 2019-12-24 16:04:51
问题 I have the following code let manager = AFHTTPRequestOperationManager() manager.POST( "http://shipeala.redmintlabs.com/api/orders/create", parameters: params, constructingBodyWithBlock: { (formData : AFMultipartFormData!) -> Void in formData.appendPartWithFileData(SHOrderImage.getInstance().image!, name: "photo", fileName: "image.jpg", mimeType: "image/*") }, success: { (operation: AFHTTPRequestOperation!, "" }, failure: { (operation: AFHTTPRequestOperation!, error: NSError!) -> Void in "" }

Loading imageviews with AFNetworking via JSON hierarchy and objectForKey

落花浮王杯 提交于 2019-12-24 14:34:26
问题 Very new to AFNetworking , but after many SO questions... I've concluded that this is the solution to my issue. I've got a hierarchy of JSON data loading my TableViewController cells dynamically. All of my text strings are loading appropriately but the image from my URL is not making it to my imageview. Before utilizing the AFNetworking library, I had the images loaded, but I was experiencing some issues with the photos not staying loaded when I scrolled away and returned (they had to load

AFNetworking 2.0 how to put some parameters in the query string of a POST request

南笙酒味 提交于 2019-12-24 12:33:52
问题 I need to call a ws to send an image to a server. Who mades the webserver, decided that the session token should be sent trough the URL and not in the body. The query should look like: http://api.service.com/imageupload.php?token=434353435 and in the body there should be the image with its parameter. The session manager when I use the -POST methods puts all the parameter inside the body. Is there a way to say to the request serializer to put some parameters in the query string and others in

Using AFNetworking 2.0 with background tasks

試著忘記壹切 提交于 2019-12-24 04:38:08
问题 I'm having issues implementing background tasks using AFURLSessionManager. I'm creating a new AFHTTPSessionManager with BaseURL and SessionConfiguration, using NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier: and using the convenience method to create a POST request. When I run my app, the first request is sent normally, but the second one returns A background URLSession with identifier {ID} already exists! and it crashes the app. I've watched Apple's WWDC 2013 videos

AFNetworking fails to resume downloads when “Content-Encoding: gzip” is set

倾然丶 夕夏残阳落幕 提交于 2019-12-23 20:53:01
问题 I'm using AFNetworking2 to download files from my AWS S3 bucket Everything works fine except when I set the Content-Encoding: gzip for the files. AFNetworking fails to download the partial content response coming back from the server and it gives me the following error: Error Domain=NSURLErrorDomain Code=-1015 "cannot decode raw data" UserInfo=0x10d2d8ce0 {NSUnderlyingError=0x10d1ace80 "cannot decode raw data", NSErrorFailingURLStringKey= http://s3.amazonaws.com/awdtest/fullzip.pdf ,

Working with two different baseUrl - AFHTTPSessionManager

走远了吗. 提交于 2019-12-23 14:20:02
问题 I am using AFHTTPSessionManager to make api calls on the web. I have signleton object of session manager and it initiates the base url once. Occasionally, I am in a need of making api call with different baseurl. And its readonly in AFNetworking.h file. What is the proper way of handing different baseurl here? Plese help. + (ApiClient *)sharedClient { static ApiClient *_sharedClient = nil; static dispatch_once_t oncePredicate; dispatch_once(&oncePredicate, ^{ _sharedClient = [[self alloc]