afnetworking-3

AFNetworking 3 x-www-form-urlencoded post data

China☆狼群 提交于 2019-12-05 23:35:54
问题 I'm trying to post data with x-www-form-urlencoded body. Posting via postman, it is ok But i cant do it via afnetworking 3. Here is my code NSDictionary *parameters = @{@"login" : email, @"password": password}; NSError *error; NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:&error]; NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; self.requestSerializer = [AFJSONRequestSerializer serializer]; NSString

AFNetworking 3.0 The data couldn’t be read because it isn’t in the correct format

六眼飞鱼酱① 提交于 2019-12-05 10:25:07
There are other questions with similar titles but none of them helped me. I've to send a PUT request to server in order to change the status of appointment so I've made this method -(void)appointmentStatusChangedTo:(NSString *)statusID atAppointmentID:(NSString *)appointmentID In which I'm setting the URL and Parameters as NSString *string = [NSString stringWithFormat:@"%@/API/Appointments/3",BaseURLString]; NSDictionary *para = @{ @"AppointmentStatusId":statusID, @"ID":appointmentID }; Then I've made URL request as AFURLSessionManager *manager = [[AFURLSessionManager alloc]

AFNetworking 3 x-www-form-urlencoded post data

空扰寡人 提交于 2019-12-04 05:12:28
I'm trying to post data with x-www-form-urlencoded body. Posting via postman, it is ok But i cant do it via afnetworking 3. Here is my code NSDictionary *parameters = @{@"login" : email, @"password": password}; NSError *error; NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:&error]; NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; self.requestSerializer = [AFJSONRequestSerializer serializer]; NSString *urlString = [NSString stringWithFormat:@"%@/%@", HTTPBaseRequestURL, appendLoginUrl]; NSLog(@"URL %@

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 3.x multipart form upload

本秂侑毒 提交于 2019-11-28 12:31:27
I have an upload form like this: <form action="http://localhost/upload.php" method="post" enctype="multipart/form-data"> <input type="file" id="upload" name="upload" /> </form> and php code to proceed upload form: isset($_FILES["upload"]) or die("Error"); // Path prepare stuff if (move_uploaded_file($_FILES["upload"]["tmp_name"], $outputFile)) { // Other processing stuffs } In xcode, Im constructing the request like this: NSMutableURLRequest* request = [[AFHTTPRequestSerializer serializer] multipartFormRequestWithMethod:@"POST" URLString:@"http://localhost/upload.php" parameters:nil

get responseObject on failure block AFNetworking 3.0

南楼画角 提交于 2019-11-28 07:21:52
how can I get the response string from failure block in AFNetworking 3.x, In the 2.x version the way to do it was: [manager GET:path parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) { NSDictionary *dictionary_FetchResult = responseObject; } failure:^(AFHTTPRequestOperation *operation, NSError *error) { NSDictionary *dictionary_FetchResult = operation.responseObject; }]; but in the 3.x version there is no operation in the returning block's parameter as shown below: [manager POST:path parameters:parameters progress:^(NSProgress * _Nonnull uploadProgress) { }

AFNetworking 3.x multipart form upload

[亡魂溺海] 提交于 2019-11-27 07:01:10
问题 I have an upload form like this: <form action="http://localhost/upload.php" method="post" enctype="multipart/form-data"> <input type="file" id="upload" name="upload" /> </form> and php code to proceed upload form: isset($_FILES["upload"]) or die("Error"); // Path prepare stuff if (move_uploaded_file($_FILES["upload"]["tmp_name"], $outputFile)) { // Other processing stuffs } In xcode, Im constructing the request like this: NSMutableURLRequest* request = [[AFHTTPRequestSerializer serializer]

get responseObject on failure block AFNetworking 3.0

依然范特西╮ 提交于 2019-11-27 05:45:06
问题 how can I get the response string from failure block in AFNetworking 3.x, In the 2.x version the way to do it was: [manager GET:path parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) { NSDictionary *dictionary_FetchResult = responseObject; } failure:^(AFHTTPRequestOperation *operation, NSError *error) { NSDictionary *dictionary_FetchResult = operation.responseObject; }]; but in the 3.x version there is no operation in the returning block's parameter as