afnetworking

AFNetworking Post Request with json feedback

可紊 提交于 2019-12-17 23:24:07
问题 I am using AFNetworking and creating a post request for which I require json feedback. The code below works however I have two main questions; where do I release the ActivityIndicator Manager? The second question is this code correct, being new I get confused with blocks so I really want to know if I am doing it right thing for optimum performance, even though it works. NSURL *url = [NSURL URLWithString:@"mysite/user/signup"]; AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL

Wanted: Up-to-date example for JSON/POST with basic auth using AFNetworking-2

懵懂的女人 提交于 2019-12-17 22:36:49
问题 I have a toy app which submits an https JSON/POST using basic auth security. I've been told I should consider using AFNetworking. I've been able to install AFNetwork-2 into my XCode project (ios7 target, XCode5) just fine. But none of the examples out there seem to be relevant to current versions of AFNetworking-2, but rather previous versions. The AFNetworking docs are pretty sparse, so I'm struggling how to put the pieces together. The non-AFNetworking code looks something like: NSURL *url

How to use Alamofire with custom headers for POST request

痞子三分冷 提交于 2019-12-17 22:14:56
问题 I implemented a POST request with Alamofire with a custom header, because we work with OAuth2 and we have to send an access token in every request inside the header. In this case I have to use a custom header. The access token value for the HTTP header field Authorization does not work for me. The server generates an error because the header information for OAuth with the access token is not available. But what is the mistake in my code? Here is my current code: let URL = NSURL(string: url +

Get url shortened with Google API, AFNetworking in Swift

霸气de小男生 提交于 2019-12-17 21:12:59
问题 In Google documentation (https://developers.google.com/url-shortener/v1/getting_started), to use Google URL shortener, I should make a request as below: POST https://www.googleapis.com/urlshortener/v1/url Content-Type: application/json {"longUrl": "http://www.google.com/"} They also stated that I will have to authenticate: "Every request your application sends to the Google URL Shortener API needs to identify your application to Google. There are two ways to identify your application: using

Parse JSON response with AFNetworking

社会主义新天地 提交于 2019-12-17 18:55:27
问题 I've setup a JSON post with AFNetworking in Objective-C and am sending data to a server with the following code: AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; NSDictionary *parameters = @{@"name": deviceName, @"model": modelName, @"pin": pin}; manager.requestSerializer = [AFJSONRequestSerializer serializer]; [manager.requestSerializer setValue:@"Content-Type" forHTTPHeaderField:@"application/json"]; [manager POST:@"SENSORED_OUT_URL" parameters:parameters

UIImageView+AFNetworking setImageWithURL with animation

℡╲_俬逩灬. 提交于 2019-12-17 17:54:30
问题 With AFNetworking, is very simple to download an image from a server and put into an UIImageView: [imageView setImageWithURL:[NSURL URLWithString:@"http://i.imgur.com/r4uwx.jpg"] placeholderImage:[UIImage imageNamed:@"placeholder-avatar"]]; How about if I want to do this replacement of image with an effect (maybe fade)??? It's because I want to make a slideshow with a lot of images. 回答1: You can use animateWithDuration in conjunction with the rendition of setImageWithURL that supplies the

Twitter OAuth and accessToken to GET statuses/user_timeline in Objective-C

我是研究僧i 提交于 2019-12-17 17:52:52
问题 I'm trying to acquire the accessToken value from Twitter for using it in my app (I need to use API v1.1's Authentication Model for GET statuses/user_timeline ); I have registered my app on api.twitter.com, imported the AFOAuth1Client classes in the project, and this is the simple code: - (void)viewDidLoad { self.twitterClient = [[AFOAuth1Client alloc] initWithBaseURL: [NSURL URLWithString:@"https://api.twitter.com/"] key:@"MYKEY" secret:@"MYSECRETKEY"]; AFOAuth1Token *accessToken; [self

AFNetworking and No Internet Connection scenario

人走茶凉 提交于 2019-12-17 17:32:00
问题 I use AFNetworking in my app for every request (like login, get data from url, etc). Take this for example: an user click on the login button and there's no connection, how to instantly display a UIAlertView that says the error? The only way is to wait the request timeout and execute the failure block? Isn't there a way that instantly check if there's connection or not? Thanks! 回答1: As of 0.9, AFHTTPClient actually has network reachability built-in (a simpler interface to Apple's

AFNetworking : How to know if response is using cache or not ? 304 or 200

走远了吗. 提交于 2019-12-17 15:44:24
问题 I can't find any answer to my question, may be I miss something... When I ask for a url, I need to know if the response comes from the cache or from the net. Is the status code 304 or 200 ? (but AFNetworking always responde 200) With ASIHTTPRequest I used to check " didUseCachedResponse " from ASIHTTPRequest , this was perfect. 回答1: I think I found a solution to determine if response was returned from cache or not using AFNetworking 2.0. I found out that each time a new response is returned

Download a file / image with AFNetworking in iOS?

Deadly 提交于 2019-12-17 15:35:46
问题 I thought I had it figured out but I just can't get it to work. I have a method that is called on every URL in an array. This method have a URL of a picture that should be downloaded in specific path in a Application Support folder for offline use. But maybe I'm misinterpreting the methods in the AFNetwork library. My method looks like this: - (void) downloadImageInBackground:(NSDictionary *)args{ @autoreleasepool { NSString *photourl = [args objectForKey:@"photoUrl"]; NSString *articleID =