afnetworking-2

Posting JSON data using AFNetworking 2.0

此生再无相见时 提交于 2019-11-27 00:14:07
I have a web script which accepts JSON string as input through HTTP POST request. I have came across several AFNetworking 1.x example for the same , can anybody please point me or give AFNetworking 2.0 example to do an HTTP POST request to a web script with formatted JSON as input ? Thanks after searching docs and trying out some codes I got following as an example AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; manager.requestSerializer = [AFJSONRequestSerializer serializer]; NSDictionary *params = @ {@"user" :txtUserName, @"pwd" :txtPwd }; [manager POST:URL

AFNetworking 2.0 track file upload progress

筅森魡賤 提交于 2019-11-27 00:04:17
问题 I am relatively new to AFNetworking 2.0. Using the code snippet below, I've been able to successfully upload a photo to my url. I would like to track the incremental upload progress, but I cannot find an example of doing this with version 2.0. My application is iOS 7, so I've opted for AFHTTPSessionManager. Can anyone offer an example of how to modify this snippet to track upload progress? AFHTTPSessionManager *manager = [AFHTTPSessionManager manager]; NSData *imageData =

AFnetworking 2.2.0 upload image on server issues

余生长醉 提交于 2019-11-26 21:42:38
问题 The reason why ask you have to do it because I confuse about params. As I understood there one way how to do it using multi part request. This way offers us two concepts as I understood upload from file that can be stored in Document directory or using NSData object. Upload from the file: So I have saved test.jpg to the document directory. Then I make NSURL instance to use it in multi part request. The code below shows how I create NSURL instance: NSString *fileName = @"test.jpg"; NSString

How to download image with AFNetworking 2.0?

陌路散爱 提交于 2019-11-26 19:01:45
问题 Appareantly there is no AFImageRequestOperation , but only AFImageResponseSerializer and frankly I don't get it or maybe I'm just looking too long through AFNetworking site... Downloading images with previous AFNetworking was like a charm. I'd hate to go back to older AFnetworking, since I did almost all stuff via the new version... Anyone? 回答1: SO you want something like this for 2.0. AFHTTPRequestOperation *requestOperation = [[AFHTTPRequestOperation alloc] initWithRequest:urlRequest];

Uploading image with AFNetworking 2.0

我与影子孤独终老i 提交于 2019-11-26 17:19:57
I'm banging my head against the wall with this one. I want to select UIImage from library and upload it to server, like on could do with <form action="http://blabla.request.cfm" method="post" enctype="multipart/form-data"> . Instead of success I got this error: 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=0x145e5d90 {NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.} I tried this way:

&#39;Project Name&#39; was compiled with optimization - stepping may behave oddly; variables may not be available

有些话、适合烂在心里 提交于 2019-11-26 15:01:32
Trying to step into AFNetworking code generates following warning: [Project Name] was compiled with optimization - stepping may behave oddly; variables may not be available. And of course I'm not able to debug the code. To be specific I'm trying to debug UIImageView+AFNetworking category which seems impossible. Changing the code has no effect (tried NSLog , etc) and when trying to step in compilers goes to assembly code and shows UIImageView+TVASTAFNetworking as category name which does not exist anywhere in the code base. Using Xcode 7. iOS 9 & 8. Cocoapods (no Framework) UPDATE I forgot to

What is “error in __connection_block_invoke_2: Connection interrupted” in iOS?

独自空忆成欢 提交于 2019-11-26 14:16:11
问题 I am tried to make iOS Application using AFNetworking in UITableView . TableView loads 20 datas like Twitter's timeline. When it loads over 80 datas, Xcode shows spending about 70MB memory and console shows "Received memory warning." And **"error in __connection_block_invoke_2: Connection interrupted".** What is this and How do I treat this error? 回答1: Reason: When you load more data which contains above 70 mb will get crash. Sol: Load data (EG:)40 only at a time. Then load another (EG:)40

AFNetworking Post Request

﹥>﹥吖頭↗ 提交于 2019-11-26 12:01:44
I'm a newbie in obj-c and have been using asihttp for some of my projects. When doing a post request in asihttp its done this way. ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url]; [request setPostValue:height forKey:@"user[height]"]; [request setPostValue:weight forKey:@"user[weight]"]; [request setDelegate:self]; [request startAsynchronous]; How would go about doing this is AFNetworking with a code example ? I already got the get Json getrequest working in AFNetworking but this post request is giving me some problems. Thanks for help in advance. It's first worth adding

iOS Image upload via AFNetworking 2.0

[亡魂溺海] 提交于 2019-11-26 09:29:26
问题 I\'ve been looking examples for the new AFNetworking 2.0 to upload images. But I\'m hitting wall and couldn\'t figure out what\'s wrong with the code. So this is the code I used NSData *imageData = UIImageJPEGRepresentation(image, 0.5); NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration]; NSURL *URL = [NSURL URLWithString:@\"http://myserverurl

How to get download progress in AFNetworking 2.0?

流过昼夜 提交于 2019-11-26 09:27:34
问题 I am using AFURLSessionManager to create a new download task: AFURLSessionManager* manager = ... NSProgress* p = nil; NSURLSessionDownloadTask* downloadTask = [manager downloadTaskWithRequest:request progress:&p destination:^NSURL*(NSURL* targetPath, NSURLResponse* response) {...} completionHandler:^(NSURLResponse* response, NSURL* filePath, NSError* error) {...} ]; [downloadTask resume]; The file gets downloaded fine, however, how do I get progress notifications? p is always set to nil. I\