AFNetworking Crash Course
25 posts
• Page 1 of 3 • 1, 2, 3
AFNetworking Crash Course
This is the official thread to discuss the following blog post: AFNetworking Crash Course
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
Ray Wenderlich
Blog: http://www.raywenderlich.com
Twitter: http://twitter.com/rwenderlich
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
Ray Wenderlich
Blog: http://www.raywenderlich.com
Twitter: http://twitter.com/rwenderlich
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
-

rwenderlich - Site Admin
- Posts: 1776
- Joined: Thu Dec 23, 2010 4:14 pm
- Has thanked: 26 times
- Been thanked: 186 times
Re: AFNetworking Crash Course
Hi Scott,
your crash course if wonderful! I really loved it...
Just one thing: what about using AFNetworking with OAuth?
There are some extensions like AFOAuth1Client and AFOAuth2Client but I couldn't find anything on the web.
Can you check them out?
Thank you and congrats again!
Matteo
your crash course if wonderful! I really loved it...
Just one thing: what about using AFNetworking with OAuth?
There are some extensions like AFOAuth1Client and AFOAuth2Client but I couldn't find anything on the web.
Can you check them out?
Thank you and congrats again!
Matteo
------------------------------
WishOnList for iPhone: http://is.gd/w6w1OV
Website: http://www.matthewlabs.com/
Dev Twitter: http://twitter.com/MatthewLabs
Personal Twitter: http://twitter.com/Matthew_Web
------------------------------
WishOnList for iPhone: http://is.gd/w6w1OV
Website: http://www.matthewlabs.com/
Dev Twitter: http://twitter.com/MatthewLabs
Personal Twitter: http://twitter.com/Matthew_Web
------------------------------
- Matthew
- n00b
- Posts: 3
- Joined: Sat Jun 11, 2011 11:23 am
- Location: Pietravairano, CE, Italy
- Has thanked: 0 time
- Been thanked: 0 time
Re: AFNetworking Crash Course
Scott,
Nice tute!
One thing you might mention. AFNEtworking has a nasty habit of not recognising web servers that don't support application/json MIME type. This causes it give an error. I could never get the property of the object to work I ended up modifying the .m file but if making a call to a url that has .json as the extension and the server does not have a json MIME type set up AFNetworking won't recognise the file.
Nice tute!
One thing you might mention. AFNEtworking has a nasty habit of not recognising web servers that don't support application/json MIME type. This causes it give an error. I could never get the property of the object to work I ended up modifying the .m file but if making a call to a url that has .json as the extension and the server does not have a json MIME type set up AFNetworking won't recognise the file.
- jvanlint
- Uber Haxx0r
- Posts: 55
- Joined: Wed Oct 19, 2011 9:26 pm
- Has thanked: 0 time
- Been thanked: 1 time
Re: AFNetworking Crash Course
jvanlint wrote:Scott,
Nice tute!
One thing you might mention. AFNEtworking has a nasty habit of not recognising web servers that don't support application/json MIME type. This causes it give an error. I could never get the property of the object to work I ended up modifying the .m file but if making a call to a url that has .json as the extension and the server does not have a json MIME type set up AFNetworking won't recognise the file.
Thanks Javanlint.
I can't say I have come across that is your server side script returning the correct MIME type? I typically just add it to the response header in my php scripts, header("Content-Type: application/json");
Thanks,
Scott
Last edited by ssherwood on Tue Mar 19, 2013 9:27 am, edited 1 time in total.
- ssherwood
- iOS Tutorial Team Member
- Posts: 4
- Joined: Sun Mar 17, 2013 10:21 pm
- Has thanked: 0 time
- Been thanked: 0 time
Re: AFNetworking Crash Course
Matthew wrote:Hi Scott,
your crash course if wonderful! I really loved it...
Just one thing: what about using AFNetworking with OAuth?
There are some extensions like AFOAuth1Client and AFOAuth2Client but I couldn't find anything on the web.
Can you check them out?
Thank you and congrats again!
Matteo
Hello Matthew,
I have not used them but I can take a look.
Thanks,
Scott
- ssherwood
- iOS Tutorial Team Member
- Posts: 4
- Joined: Sun Mar 17, 2013 10:21 pm
- Has thanked: 0 time
- Been thanked: 0 time
Re: AFNetworking Crash Course
Hello,
Tutorial uses a deprecated method:
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
Deprecated in iOS 6.0
locationManager:didUpdateToLocation:fromLocation:
Tells the delegate that a new location value is available. (Deprecated in iOS 6.0. Use locationManager:didUpdateLocations: instead.)
Regards,
Marc
Tutorial uses a deprecated method:
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
Deprecated in iOS 6.0
locationManager:didUpdateToLocation:fromLocation:
Tells the delegate that a new location value is available. (Deprecated in iOS 6.0. Use locationManager:didUpdateLocations: instead.)
Regards,
Marc
- Marc
- n00b
- Posts: 1
- Joined: Tue Oct 23, 2012 8:39 am
- Has thanked: 0 time
- Been thanked: 0 time
Re: AFNetworking Crash Course
Thanks for the tutorial! Aside from the deprecated CLLocationManager method, I had to change parser:didEndElement:namespaceURI:qualifiedName: because it was creating an NSArray instead of a mutable one and then trying to add an object to it. Maybe I mistyped something but here is the updated method with the change highlighted in bold:
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{
if ([qName isEqualToString:@"current_condition"] || [qName isEqualToString:@"request"]) {
[self.xmlWeather setObject:[NSMutableArray arrayWithObject:self.currentDictionary] forKey:qName];
self.currentDictionary = nil;
}
else if ([qName isEqualToString:@"weather"]) {
NSMutableArray *array = [self.xmlWeather objectForKey:@"weather"];
if (!array) {
array = [NSMutableArray array];
}
[array addObject:self.currentDictionary];
[self.xmlWeather setObject:array forKey:@"weather"];
self.currentDictionary = nil;
}
else if ([qName isEqualToString:@"value"]) {
// ignore value tags -- they only appear in the two conditions below
}
else if ([qName isEqualToString:@"weatherDesc"] || [qName isEqualToString:@"weatherIconUrl"]) {
[self.currentDictionary setObject:[NSArray arrayWithObject:[NSDictionary dictionaryWithObject:self.outString forKey:@"value"]] forKey:qName];
}
else {
[self.currentDictionary setObject:self.outString forKey:qName];
}
self.elementName = nil;
}
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{
if ([qName isEqualToString:@"current_condition"] || [qName isEqualToString:@"request"]) {
[self.xmlWeather setObject:[NSMutableArray arrayWithObject:self.currentDictionary] forKey:qName];
self.currentDictionary = nil;
}
else if ([qName isEqualToString:@"weather"]) {
NSMutableArray *array = [self.xmlWeather objectForKey:@"weather"];
if (!array) {
array = [NSMutableArray array];
}
[array addObject:self.currentDictionary];
[self.xmlWeather setObject:array forKey:@"weather"];
self.currentDictionary = nil;
}
else if ([qName isEqualToString:@"value"]) {
// ignore value tags -- they only appear in the two conditions below
}
else if ([qName isEqualToString:@"weatherDesc"] || [qName isEqualToString:@"weatherIconUrl"]) {
[self.currentDictionary setObject:[NSArray arrayWithObject:[NSDictionary dictionaryWithObject:self.outString forKey:@"value"]] forKey:qName];
}
else {
[self.currentDictionary setObject:self.outString forKey:qName];
}
self.elementName = nil;
}
Re: AFNetworking Crash Course
First I want to thank you for an excellent tutorial. Secondly, I'm encountering a problem that I wonder if anyone might help me with.
When I run the app after implementing the HTTPClient section, and I tap either "HTTP POST" or "HTTP GET" in the action sheet, the app crashes in numberOfRowsInSection, at this line (with "all exceptions" breakpoint enabled):
NSArray *upcomingWeather = [self.weather upcomingWeather];
Debugger output is as follows:
-[__NSCFData upcomingWeather]: unrecognized selector sent to instance...
There are no compiler warnings at all. It seems that the upcomingWeather method in the NSDictionary (weather_package) category is not being recognized, but I'm not sure how to fix it. The class extension .h and .m files are in my project, and the .m is listed under "compile sources" in my build phases...tried the usual steps of quitting XCode and doing a clean, to no avail. Any thoughts? I really want to finish the tutorial!
Thanks!
-Reid
When I run the app after implementing the HTTPClient section, and I tap either "HTTP POST" or "HTTP GET" in the action sheet, the app crashes in numberOfRowsInSection, at this line (with "all exceptions" breakpoint enabled):
NSArray *upcomingWeather = [self.weather upcomingWeather];
Debugger output is as follows:
-[__NSCFData upcomingWeather]: unrecognized selector sent to instance...
There are no compiler warnings at all. It seems that the upcomingWeather method in the NSDictionary (weather_package) category is not being recognized, but I'm not sure how to fix it. The class extension .h and .m files are in my project, and the .m is listed under "compile sources" in my build phases...tried the usual steps of quitting XCode and doing a clean, to no avail. Any thoughts? I really want to finish the tutorial!
Thanks!
-Reid
Re: AFNetworking Crash Course
Hm... can't resolve the problem coming after adding AFNetworking folder to the project. Even after adding
to the Prefix.pch, I still can't run the application with two warnings:
.../AFNetworking/AFHTTPClient.h:83:2: SystemConfiguration framework not found in project, or not included in precompiled header. Network reachability functionality will not be available.
.../AFNetworking/AFHTTPClient.h:88:2: MobileCoreServices framework not found in project, or not included in precompiled header. Automatic MIME type detection when uploading files in multipart requests will not be available.
and an error:
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang failed with exit code 254
What's wrong with it? AFNetworking was cloned from github just today. XCode 4.6.1. Please, help
- Code: Select all
#import <MobileCoreServices/MobileCoreServices.h>
#import <SystemConfiguration/SystemConfiguration.h>
to the Prefix.pch, I still can't run the application with two warnings:
.../AFNetworking/AFHTTPClient.h:83:2: SystemConfiguration framework not found in project, or not included in precompiled header. Network reachability functionality will not be available.
.../AFNetworking/AFHTTPClient.h:88:2: MobileCoreServices framework not found in project, or not included in precompiled header. Automatic MIME type detection when uploading files in multipart requests will not be available.
and an error:
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang failed with exit code 254
What's wrong with it? AFNetworking was cloned from github just today. XCode 4.6.1. Please, help
Re: AFNetworking Crash Course
Congratulation for your tutorial is fantastic. I have one question, can it be used with web services developed with SOAP? If not do you know a way to consume SOAP Web services.
Thank yo very much!!!!!
Thank yo very much!!!!!
25 posts
• Page 1 of 3 • 1, 2, 3
Who is online
Users browsing this forum: Google [Bot] and 8 guests