Tag: afnetworking

Get UIImageView using Afnetworking and put it in an array

As the title says, i need to get the image and put it in an array. UIImageView *myImage = [[UIImageView alloc] init]; [myImage setImageWithURL:[NSURL URLWithString:@”http://host.com/images/1/1.png”] placeholderImage:[UIImage imageNamed:@”page3.png”]]; [items addObject:myImage]; the problem is that while the image is being loaded, the code continues and nothing gets put in the array, actually I guess an empty UIImageView […]

Parsing an XML file with AFNetworking

I am making a little weather app using the Yahoo api. This api gives me an XML file back. My problem is now how I can parse this file ? Here is my code that I have so far. AFXMLRequestOperation *operation = [AFXMLRequestOperation XMLParserRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, NSXMLParser *XMLParser) { NSLog(@”success”); XMLParser.delegate = self; […]

iOS AFNetworking – ASP.NET Web API .ASPXAUTH storage and deletion

I’m using the AFNetworking Framework for iOS. I’ve subclassed AFHttpClient and are using it as a singleton, i.e. [TestAFClient sharedClient] I’m consuming an ASP.NET Web Service API that requires the use of the .ASPXAUTH cookie. First I have to authenticate, receive the .ASPXAUTH cookie in response, and then must pass this cookie with each subsequent […]

How do you get mutable dictionaries from AFNetworking and AFJSONRequestOperation?

I’m using JSONKit with AFNetworking’s AFHTTPClient (with AFJSONRequestOperation) and I can’t seem to figure out how one might trigger the use of the mutableObjectFrom… methods of JSONKit rather than the normal parser methods which return (or arrays of) JKDictionary. Is this possible without modifying AFNetworking?

iOS background fetch time limit crash

I’ve set up background fetch, using outline from NSScreencast episode #92. – (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { … [application setMinimumBackgroundFetchInterval:UIApplicationBackgroundFetchIntervalMinimum]; … } – (void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { if ([[MyAppAPIClient manager] reachable] && [[Session manager] userSignedIn]) { [[[Session manager] user] fetchBackgroundWithSuccess:^(NSURLSessionDataTask *task, NSDictionary *responseObject) { completionHandler(UIBackgroundFetchResultNewData); } failure:^(NSURLSessionDataTask *task, NSError *error) { completionHandler(UIBackgroundFetchResultFailed); }]; } […]

AFNetworking version 2 content-type error

I’m attempting to make an iphone app that will interact with a particular JIRA server. I’ve got the following code to log in: NSURL *url = [[NSURL alloc] initWithString:@”https://mycompany.atlassian.net/rest/auth/latest/session/”]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; [request setHTTPMethod:@”POST”]; NSString *postString = [NSString stringWithFormat:@”{\”username\”:\”%@\”,\”password\”:\”%@\”}”, username, password]; [request setHTTPBody:[postString dataUsingEncoding:NSUTF8StringEncoding]]; AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; [request setValue:@”application/json” forHTTPHeaderField:@”Accept” […]

Property Has a Previous Declaration

I tried adding XMPP framework into my ios project and I couldn’t get it working. Turns out I added it incorrectly, So I tried removing it and now without XMPP I am getting these errors: Thanks in Advance!

Valid JSON, but 'Cocoa error 3840' from AFNetworking/NSJSONSerialization

I’ve been hacking away for hours trying to solve this problem to no avail – it seems like my only option is to post here to see if anyone can shed some light on this issue. It may be an issue with AFNetworking, or (more likely), it may be an issue with my code. The […]

why is RestKit changing my response content-type?

In short: I try to fetch data form the server with the content-type of the http request header set as @”text/html.. but for some reason RestKit changes that to application/JSON Explanation: If I were to make this request using just AFNetworking.. things work like a charm.. this is what my AFNetworking code looks like: AFHTTPClient […]

Posting JSON as the body of a POST request using AFHTTPClient

I am trying to find a way, using AFNetworking, to set the Content-Type header to be application/json and to POST with JSON in the body. The methods that I’m seeing in the documentation (postPath and requestWithMethod) both take a dictionary of parameters, which I assume is encoded in the standard form syntax. Does anyone know […]