afnetworking-2

Cancel Post request in Afnetworking 2.0

梦想的初衷 提交于 2019-12-01 03:26:17
问题 Hi I am making post request using AFnetworking 2.0. My request looks like this. AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; manager.responseSerializer = [AFXMLParserResponseSerializer serializer]; [manager.requestSerializer setValue:@"some value" forHTTPHeaderField:@"x"]; [manager POST:url parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) { //doing something } failure:^(AFHTTPRequestOperation *operation, NSError *error) { /

POST with URL parameters and JSON body in AFNetworking

只愿长相守 提交于 2019-11-30 21:11:24
I'd like to make a POST call that has both URL parameters and a JSON body: URL http://example.com/register?apikey=mykey JSON { "field" : "value"} How can I use two different serializers at the same time with AFNNetworking? Here's my code with the URL parameters missing: AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; manager.responseSerializer = [AFJSONResponseSerializer serializer]; [manager POST:@"http://example.com/register" parameters:json success:^(AFHTTPRequestOperation *operation, id responseObject) { I make a post method /** * Services gateway * Method

Subclass AFHTTPRequestOperationManager?

我是研究僧i 提交于 2019-11-30 20:55:48
I find myself repeating a lot of code using AFHTTPRequestOperationManager throughout my code, so I was thinking about subclassing it, so I can set it up once as a singleton, and put all the code in the subclass, as opposed to have it spread out through my project. However on the NSHipster episode on AFNetworking 2.0 ( http://nshipster.com/afnetworking-2/ ), it says: The main difference in 2.0 is that you'll actually use this class directly, rather than subclass it, for reasons explained in the "Serialization" section. Since AFNetworking and NSHipster have the same author, I regard this a valid

Subclass AFHTTPRequestOperationManager?

99封情书 提交于 2019-11-30 17:45:52
问题 I find myself repeating a lot of code using AFHTTPRequestOperationManager throughout my code, so I was thinking about subclassing it, so I can set it up once as a singleton, and put all the code in the subclass, as opposed to have it spread out through my project. However on the NSHipster episode on AFNetworking 2.0 (http://nshipster.com/afnetworking-2/), it says: The main difference in 2.0 is that you'll actually use this class directly, rather than subclass it, for reasons explained in the

How to work with large file uploads in ios?

梦想与她 提交于 2019-11-30 14:15:43
My app requires upload of video files from users phone which will then be processed on server. THe problem is the size of the file can go to 200 MB plus and the user won't keep the application open to wait for the file to upload. Since apple doesn't allow apps to run in background for more than a limited time. How can I ensure that my files are uploaded. I am using afnetworking to set up an upload task as given by ios 7 library. Please if anyone can point me in the right direction or have any solution it would be greatly appreciated. I have banged my head on this for too long. Thanks.

AFNetworking 2.0 HTTP POST Progress

蹲街弑〆低调 提交于 2019-11-30 14:08:39
问题 How can I get the progress of an AFHTTPRequest? I've tried searching all over the net. I am using: AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; NSDictionary *params = @{@"gameId" : datas[0], @"p1": datas[1], @"p2":datas[2], @"turn":datas[3] }; manager.requestSerializer = [AFHTTPRequestSerializer serializer]; manager.responseSerializer = [AFHTTPResponseSerializer serializer]; [manager POST:@"http://localhost/thepath/isprivate/thefile.php" parameters:params

AFNetworking 2: How to cancel a AFHTTPRequestOperationManager request?

牧云@^-^@ 提交于 2019-11-30 10:38:20
问题 I migrated my networking functionality from AFNetworking to AFNetworking v2 and instead of AFHttpClient I am using AFHTTPRequestOperationManager to support iOS6 as well. My issue is that while in AFHttpClient there was the functionality to cancel a pending request using the - (void)cancelAllHTTPOperationsWithMethod:(NSString *)method path:(NSString *)path; method, in the AFHTTPRequestOperationManager there is no such obvious method. What I've done up to now is subclassing

POST with URL parameters and JSON body in AFNetworking

痴心易碎 提交于 2019-11-30 05:46:14
问题 I'd like to make a POST call that has both URL parameters and a JSON body: URL http://example.com/register?apikey=mykey JSON { "field" : "value"} How can I use two different serializers at the same time with AFNNetworking? Here's my code with the URL parameters missing: AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; manager.responseSerializer = [AFJSONResponseSerializer serializer]; [manager POST:@"http://example.com/register" parameters:json success:^

AFNetworking-2 waitUntilFinished not working

烂漫一生 提交于 2019-11-30 05:30:39
I know there is another similar question , but it's for an older version of AFNetworking, and doesn't really answer it anyway. I have the following code: AFHTTPRequestOperationManager* manager = [AFHTTPRequestOperationManager manager]; manager.securityPolicy.allowInvalidCertificates = YES; manager.requestSerializer = [AFJSONRequestSerializer serializer]; [manager.requestSerializer setAuthorizationHeaderFieldWithUsername: currentUser() password: currentPassword()]; __block NSDictionary* response = nil; AFHTTPRequestOperation* operation = [manager GET: @"https://10.20.30.40:8765/foobar"

AFNetworking 2.0 Get JSON from code 400 in failure block

独自空忆成欢 提交于 2019-11-30 04:48:15
问题 I'm using AFHTTPRequestOperationManager for a POST request. Now I'm deliberately entering incorrect information to handle a 400 error code. Now, the web service actually returns a JSON with a message explaining to the user what they've done wrong. I would very much like to get this JSON to display the message in a UIAlertView . However, the failure block of: [operationManager POST:ServerURL parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) { NSLog(@"Success