afnetworking

is there an example of AFHTTPClient posting json with AFNetworking?

[亡魂溺海] 提交于 2019-12-31 21:42:12
问题 Looking for an example of how to post json with AFHTTPClient . I see that there is a postPath method which takes an NSDictionary and the AFJSONEncode method returns an NSData . Is there an easy way to serialize an object to NSDictionary , or is there an easier way using jsonkit? I just need to post the object as json to a REST API. UPDATE: So I tried passing a dictionary over but it seems to break on serializing a nested array. For example, if I have an object: Post* p = [[Post alloc] init];

AFHTTPRequestOperationManager return data in block

安稳与你 提交于 2019-12-31 07:15:44
问题 I created an APIController in my application that has several methods that call specific api urls and return a model object populated with the result of the api call. The api works with json and up to now my code looks like the following: //Definition: - (MyModel *)callXYZ; - (MyModel *)callABC; - (MyModel *)call123; //Implementation of one: - (MyModel *)callXYZ { //Build url and call with [NSData dataWithContentsOfURL: url]; //Create model and assign data returned by api return model; } Now

User Login With AFNetworking

做~自己de王妃 提交于 2019-12-31 03:30:58
问题 I am building my first iOS app. I have got the backend code done, but I am struggling with the Objective-C part of it. I have a signup / login page. But I don't know how to send that data to my server using Objective C. I have read that AFNetworking is good, but I was wondering how I could use that for user login . I have downloaded and added AFNetworking to my XCode Project and set up headers. AFHTTPClient *client = [AFHTTPClient clientWithBaseURL:[NSURL URLWithString:@"http://examplewebsite

how to set Content-Type other than application/json

强颜欢笑 提交于 2019-12-31 00:00:48
问题 I'm trying to send a REST API to my server by AFNetworking2.0, our server only accepts Content-Type as application/vnd.mycom.mycom-csc+json when i send the request, it is json format indeed, self.operationMgr = [AFHTTPRequestOperationManager manager]; self.operationMgr.securityPolicy.allowInvalidCertificates = YES; operationMgr.responseSerializer = [AFJSONResponseSerializer serializer]; operationMgr.requestSerializer = [AFJSONRequestSerializer serializer]; self.operationMgr.responseSerializer

Streaming JSON with AFNetworking on IOS

℡╲_俬逩灬. 提交于 2019-12-30 04:50:28
问题 What would be the most elegant way to receive data from a streaming JSON API using AFNetworking? AFNetworking provides excellent support for receiving non-streaming data from JSON APIs, but I couldn't find any examples of streaming JSON. 回答1: AFNetworking does not have a built-in streaming SAX-style JSON operation, but it should be straight forward to create your own. Create a subclass of AFJSONRequestOperation Use the outputStream property of the operation during initialization to hook it up

AFNetworking background file upload

一个人想着一个人 提交于 2019-12-30 04:32:12
问题 I want to upload files to my server from my app. The code below is working great when app is active. If I press home button or open another app uploading stops. I activated background fetch but still not working. Afnetworking has background support but I cant figure out how I implement this feature to my code. NSString *str=[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Archive.zip"]; NSDictionary *parameters = @{@"foo": @"bar"}; NSURL *filePath = [NSURL

POST jpeg upload with AFNetworking

≡放荡痞女 提交于 2019-12-30 00:45:13
问题 I can't for the life of me figure out why this doesn't work when I use AFNetworking. It worked with ASIHTTP. This is all very new to me. But I can't figure out why the files are not being transferred from $_FILES to the server's HD anymore. Here's the iOS code: - (IBAction)uploadPressed { [self.fileName resignFirstResponder]; NSURL *remoteUrl = [NSURL URLWithString:@"http://mysite.com"]; NSTimeInterval timeInterval = [NSDate timeIntervalSinceReferenceDate]; NSString *photoName=[NSString

Cocoapod: Why Xcode build process try to find the library which has been already removed from my project

一世执手 提交于 2019-12-29 10:02:13
问题 Thank you always for all of your knowledge. I have checked my issue in StackOverflow and found similar issues but could not find my case specifically. Greatly appreciated If some of you could advise my situation. My environment; xcode: Version 6.0.1, ios target: IOS 8, code: OBjective-C I opened my project by Myproject.xcworkspace. Issue; I used Cocoapod to install some libraries. Here was the code in podfile. source 'https://github.com/CocoaPods/Specs.git' platform :ios, '6.0' pod

self.tableView reloadData not working after successful call in AFNetworking

与世无争的帅哥 提交于 2019-12-29 07:36:05
问题 I have a class that runs similar to the AFHTTPSessionManager component of this tutorial http://www.raywenderlich.com/59255/afnetworking-2-0-tutorial However, [self.tableView reloadData] is not working for me. I have the manager implemented as so: -(void) refresh{ manager = [[AFHTTPSessionManager...] iniwithBaseURL:...]; [manager Get:... parameters:... success:^(NSURLSessionDataTask *task, id responseObject){ //test success values in responseObject if(test){ //Get table data [self.tableView

setting limit on concurrent tasks in AFNetworking 2 running AFHTTPSessionManager

一个人想着一个人 提交于 2019-12-29 03:18:25
问题 so I know that in the old AFNetworking this was possible using the AFHTTPClient, and I know that if I use AFHTTPRequestOperationManager I can set the queue's limit, but I can't make AFHTTPSessionManager to run only x requests at a time without implementing it by myself using the success block (which I don't want to). The following code did NOT limit my connections: AFHTTPSessionManager *manager = [AFHTTPSessionManager manager]; manager.operationQueue.maxConcurrentOperationCount = 1; In line