afnetworking

AFNetworking returning NSCFData; issue with registerHTTPOperationClass [closed]

别说谁变了你拦得住时间么 提交于 2019-12-24 04:43:28
问题 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 6 years ago . I am new to AFNetworking and am making a call to a simple login api that returns json like: {"status":"success","data":{"auth_token":"12jt34"}} I'm doing

Using AFNetworking 2.0 with background tasks

試著忘記壹切 提交于 2019-12-24 04:38:08
问题 I'm having issues implementing background tasks using AFURLSessionManager. I'm creating a new AFHTTPSessionManager with BaseURL and SessionConfiguration, using NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier: and using the convenience method to create a POST request. When I run my app, the first request is sent normally, but the second one returns A background URLSession with identifier {ID} already exists! and it crashes the app. I've watched Apple's WWDC 2013 videos

Parse XML to NSDictionary

℡╲_俬逩灬. 提交于 2019-12-24 04:32:48
问题 I was using AFNetworking 1.4.3 to retrieve NSDictionary from JSON. Now I have to use new AFNetworking 2.0 to parse XML file. For example: [self getPath:path parameters:parameters success:^(AFHTTPRequestOperation *operation, NSDictionary *responseObject) { // Mapping XML to my own MR_object }failure:^(AFHTTPRequestOperation *operation, NSError *error) { // Error handling here }]; Is it possible to map XML file directly to NSDictionary without using NSXMLParser ? I am looking for equvalent for

AFNetworking 2.0 setImageWithURLRequest

故事扮演 提交于 2019-12-24 03:19:20
问题 I'm using this code when downloading images in one of my current projects and it's not working with AFNetworking 2.0. I tried going thru AFImageResponseSerializer but I can't find the right code to use. [cell.posterImage setImageWithURLRequest:urlRequest placeholderImage:[UIImage imageNamed:@"placeholder.png"] success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image) { cell.posterImage.image = image; } failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError

How to make Twilio api Post request with the help of AFNetworking?

倾然丶 夕夏残阳落幕 提交于 2019-12-24 02:56:16
问题 I want to access Twilio api using AFNetworking . I tried number of ways but not get success. Please help me, if anyone did Tiwilo post request using AFNetworking. Case 1: This is my native objective-c working code. NSString *urlString = [NSString stringWithFormat:@"https://%@:%@@api.twilio.com/2010-04-01/Accounts/%@/SMS/Messages", kTwilioSID, kTwilioSecret, kTwilioSID]; NSURL *url = [NSURL URLWithString:urlString]; NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init]; [request

How to access a third party framework from My.Framework?

江枫思渺然 提交于 2019-12-24 01:28:31
问题 Steps to understand my problem: 1) I created a framework (My.framework) 2) Added My.framework as a subproject to MyApp.xcodeproj. 3) Then I ran cocoapod for adding AFNetworking on MyApp.xcodeproj. 4) Now, I open MyApp.xcworkspace. 5) While trying to access AFNetworking from classes in My.framework. It is not accessible. P.S. I am not talking about "umbrella framework". (Umbrella framework is where we add a framework as a framework of sub project.)(Correct me here if I am wrong) I just want to

Singleton vs. third-party libraries

落爺英雄遲暮 提交于 2019-12-24 01:28:07
问题 I'm familiar with the concept of Singleton and this mechanism is pretty handy but.. What happens in case I want one, shared instance of some third-party class e.g. AFHTTPRequestOperation or maybe some Magical Record? What should I do when I'm using one object from external class in many controllers? Or maybe it is a good practice to instantiate a new object in each controller? 回答1: I'm not familiar with Magical Record but for AFNewtorking it definitely makes sense to make a singleton in many

AFNetworking synchronous calls (like/unlike)

喜夏-厌秋 提交于 2019-12-24 01:14:57
问题 I need to implement like/unlike functionality in app. All API calls are made with AFNetworking and success/errors handlers ( ios blocks ). Problem is that when user making many clicks on a button in a short period of time, some of the request are received by server in a wrong sequence and then everything becomes wrong. For example double like or double unlike happens. Is there a way to send all request via AFNetworking synchronously? If no what is the best practice to design this kind of API

JSON file set content type to application/json AFNetworking

天涯浪子 提交于 2019-12-24 00:05:28
问题 i wrote a .json file and want to download it with AFNetworking. But AFNetworking complains: fail Expected content type {( "text/json", "application/json", "text/javascript" )}, got text/plain my JSON file test.json { "count-packages": 5, "packages": { "de": { "0": "Wackel Dackel", "1": "Hans Wurst", "2": "Peter Ploes", "3": "Tiffel Toffel", "4": "China Mann" }, "en": { "0": "Wobble dachshund", "1": "Hans Sausage", "2": "Peter Ploes", "3": "Tiffel Potato", "4": "Peking Ente" } } } HTTP/1.1 200

iOS/Swift : How to manage network versatility with Alamofire

百般思念 提交于 2019-12-23 21:05:50
问题 I'm new in iOS and Swift development, and i'm not used to manage the network reachability in my usual programs. I found AFNetworking and Alamofire which are great frameworks to ease the API calls in iOS. But i have difficulties to figure out how to make some requests to wait until network is back if i'm loosing it. Typically during session login or getting some json lists or downloading images. Do you have some tutorials or examples i can rely on to improve my knowledge and be able to build a