afnetworking-2

How to do GET request via AFNetworking?

佐手、 提交于 2019-11-29 14:28:44
问题 I added directories AFNetworking and UIKit+AFNetworking to project manager. I use latest library 3.0.4 After I imported file AFNetworking.h in my class file .m . I found a lot examples how to make request to url, but information is old. How to make GET request to URL and get data from server? Now function AFHTTPRequestOperation was removed. This is first time working with libraries in xcode, I am beginner. 回答1: AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:[NSURL

AFNetworking 2.0 Send Post Request with URL Parameters

ⅰ亾dé卋堺 提交于 2019-11-29 10:10:02
How do I send a POST request with AFNetworking 2.0 with all the parameters in the URL like such: http://www.myserver.com?api_key=something&lat=2.4&radius=100 Right now I have: NSString* query = @"http://example.com?name=param&date=param"; AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; NSDictionary *parameters = @{}; [manager POST:query parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) { NSLog(@"JSON: %@", responseObject); } failure:^(AFHTTPRequestOperation *operation, NSError *error) { NSLog(@"Error: %@", error); }]; But it

convert NSTaggedPointerString to NSString

别等时光非礼了梦想. 提交于 2019-11-29 09:08:35
I had called an interface of Baidu to check id Number, however the value of Sex returned with sex = M , without "" around the M in JSON, when I use NSString in module to store it and then print the class name of this sex property, it printed as NSTaggedPointerString , I doubt how to convert it to a String to use it. Anyone have good ideas? Catfish_Man NSTaggedPointerString is already an NSString , it's just a subclass. You can use it anywhere you can use an NSString , without conversion. I have encountered places where it cannot be used as a string, such as when creating an NSDictionary. In

Swift and AFNetworking integration [closed]

℡╲_俬逩灬. 提交于 2019-11-29 09:08:01
Now as swift is the new language to develop iOS apps. How can we integrate with the AFNetworking or using NSURLSession will be a better option ??? Please help me out.. You have to add AFNetworking to your swift project In Build Settings -> Defines Module set to Yes In Build Settings -> Swift compiler -> Objective-C bridging file set the name of bridging file 'ProjectName-Bridging-Header.h' for example In ProjectName-Bridging-Header.h write: #import "AFNetworking.h" mohacs Any Objective-C framework (or C library) that’s accessible as a module can be imported directly into Swift. This includes

Passing parameter in url for GET method using afnetworking

空扰寡人 提交于 2019-11-29 08:19:33
i have url in which query is executed. https://<BASE_URL>/<TENANT_URL>/?query=where UserName='abc'&companyId=&page=1&pageSize=25&filterResultByColumns=true i am escaping the remaining part after tenant url like this, NSString *requestUrl = [[NSString stringWithFormat:@"%@/?query=where UserName='%@'&companyId=&page=1&pageSize=25&filterResultByColumns=true",<TENANT_URL>,userCredential.userName]stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; requestUrl = [NSString stringWithFormat:@"%@/%@",baseurl,requestUrl]; Here is my GET request. AFHTTPRequestOperationManager *manager =

How to use Progress parameter in AFNetworking 2.0

寵の児 提交于 2019-11-29 03:52:47
I am trying to use AFNetworking 2.0 with NSURLSession. I am using the method - (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request fromFile:(NSURL *)fileURL progress:(NSProgress * __autoreleasing *)progress completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler; How am I supposed to use the progress parameter. The method is a non blocking method. Hence I will have to listen to the ' progress ' to get the updates. But the parameter wouldn't take a property. Only takes a local variable(NSProgress * __autoreleasing *). I can't

Post Request with AFHttpRequestOperationManager not working

萝らか妹 提交于 2019-11-29 03:36:46
I am using AFHTTPRequestOperationManager to post some JSON to my server, my code is below. NSDictionary *parameters = [[NSDictionary alloc] initWithObjectsAndKeys:@"john", @"name", @"xxxxx@gmail.com", @"email", @"xxxx", @"password", @"1", @"type", nil]; // Do any additional setup after loading the view. AFSecurityPolicy *policy = [[AFSecurityPolicy alloc] init]; [policy setAllowInvalidCertificates:YES]; AFHTTPRequestOperationManager *operationManager = [AFHTTPRequestOperationManager manager]; [operationManager setSecurityPolicy:policy]; [operationManager POST:@"posturl here" parameters

Upload an image with AFNetworking 2.0

喜夏-厌秋 提交于 2019-11-29 01:34:59
问题 I can't understand why this is so hard. All the tutorials and articles online seem to be talking about the 1.0 api, which is pretty useless. I've tried a few different ways and get different results. What am I doing wrong? upload task - this seems to not be using a multipart form, wtf? NSMutableURLRequest *request = [self.manager.requestSerializer multipartFormRequestWithMethod:@"POST" URLString:[[NSURL URLWithString:url relativeToURL:[NSURL URLWithString:ApiBaseUrl]] absoluteString]

AFNetworking 2.0 - “unacceptable content-type: text/plain”

北战南征 提交于 2019-11-28 23:56:02
问题 I'm using AFNetworking 2.0 to read JSON from a service I'm building (on localhost for now) in Node. Pretty normal stuff. Node is sending JSON like so: res.setHeader('Content-Type','application/json'); res.end( JSON.stringify(...)); My iOS first-pass code is attempting to read that data like so: typedef void(^NextBlock)(); AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; manager.responseSerializer = [AFJSONResponseSerializer serializer]; [manager GET:self

Wanted: Up-to-date example for JSON/POST with basic auth using AFNetworking-2

前提是你 提交于 2019-11-28 18:41:28
I have a toy app which submits an https JSON/POST using basic auth security. I've been told I should consider using AFNetworking. I've been able to install AFNetwork-2 into my XCode project (ios7 target, XCode5) just fine. But none of the examples out there seem to be relevant to current versions of AFNetworking-2, but rather previous versions. The AFNetworking docs are pretty sparse, so I'm struggling how to put the pieces together. The non-AFNetworking code looks something like: NSURL *url = [NSURL URLWithString:@"https://xxx.yyy.zzz.aaa:bbbbb/twig_monikers"]; NSMutableURLRequest *request =