# AFNetworking 2.0 Tutorial

**URL:** <https://forums.kodeco.com/t/afnetworking-2-0-tutorial/6297>\
**Category:** 🎓 Courses & Articles\
**Created:** [March 4, 2016, 10:39am UTC](https://forums.kodeco.com/t/afnetworking-2-0-tutorial/6297 "2016-03-04T10:39:06Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![jrg.developer](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/jrg.developer/32/109958_2.png) [@jrg.developer](https://forums.kodeco.com/u/jrg.developer)\
**Post date:** [March 4, 2016, 10:39am UTC](https://forums.kodeco.com/t/afnetworking-2-0-tutorial/6297/1 "2016-03-04T10:39:06Z")

</div>

Learn how to easily get and post data from a web service in iOS in this AFNetworking 2.0 tutorial.

* * *
 This is a companion discussion topic for the original entry at [https://www.raywenderlich.com/2516-afnetworking-2-0-tutorial](https://www.raywenderlich.com/2516-afnetworking-2-0-tutorial)

---

<div class="post-metadata">

**Author:** ![payal](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/payal/32/109581_2.png) [@payal](https://forums.kodeco.com/u/payal)\
**Post date:** [May 26, 2016, 9:50am UTC](https://forums.kodeco.com/t/afnetworking-2-0-tutorial/6297/2 "2016-05-26T09:50:01Z")

</div>

Very Nice tutorial…  
Very well explained…

---

<div class="post-metadata">

**Author:** ![muaddib](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/muaddib/32/100816_2.png) [@muaddib](https://forums.kodeco.com/u/muaddib)\
**Post date:** [June 28, 2016, 5:45am UTC](https://forums.kodeco.com/t/afnetworking-2-0-tutorial/6297/3 "2016-06-28T05:45:18Z")

</div>

Can this tutorial be updated to Swift and iOS 9.3?

---

<div class="post-metadata">

**Author:** ![jrg.developer](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/jrg.developer/32/109958_2.png) [@jrg.developer](https://forums.kodeco.com/u/jrg.developer)\
**Post date:** [July 20, 2016, 8:42am UTC](https://forums.kodeco.com/t/afnetworking-2-0-tutorial/6297/4 "2016-07-20T08:42:12Z")

</div>

Unfortunately, this tutorial will not likely be updated.

If you’re already using Swift, I highly recommend you switch over to [Alamofire](https://github.com/Alamofire/Alamofire) instead. This is an excellent library by the same author of AFNetworking, [Mattt Thompson](https://twitter.com/mattt).

Along with using [AlamofireImage](https://github.com/Alamofire/AlamofireImage), it’s functionality is on par, perhaps even better than, AFNetworking.

---

<div class="post-metadata">

**Author:** ![skov](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/skov/32/107268_2.png) [@skov](https://forums.kodeco.com/u/skov)\
**Post date:** [August 10, 2016, 7:00pm UTC](https://forums.kodeco.com/t/afnetworking-2-0-tutorial/6297/5 "2016-08-10T19:00:22Z")

</div>

iv been away from coding for som time, and i made ale my apps with web api after then tutorial How To Create an App Like Instagram With a Web Service Backend – Part 1/2 2/2 and my question if can the function below still be used in AFNetworking 2.0 / 3.0 ?

```
-(void)commandWithParams:(NSMutableDictionary*)params onCompletion:(JSONResponseBlock)completionBlock {
NSData* uploadFile = nil;
if ([params objectForKey:@"file"]) {
	uploadFile = (NSData*)[params objectForKey:@"file"];
	[params removeObjectForKey:@"file"];
}

NSMutableURLRequest *apiRequest = [self multipartFormRequestWithMethod:@"POST" path:kAPIPath parameters:params constructingBodyWithBlock: ^(id <AFMultipartFormData>formData) {
	if (uploadFile) {
		[formData appendPartWithFileData:uploadFile name:@"file" fileName:@"photo.jpg" mimeType:@"image/jpeg"];
	}
}];
AFJSONRequestOperation* operation = [[AFJSONRequestOperation alloc] initWithRequest: apiRequest];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
    //success!
    completionBlock(responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    //failure :(
    completionBlock([NSDictionary dictionaryWithObject:[error localizedDescription] forKey:@"error"]);
    
}];
[operation start];
}

```

---

<div class="post-metadata">

**Author:** ![lucasmartinoia](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/lucasmartinoia/32/108887_2.png) [@lucasmartinoia](https://forums.kodeco.com/u/lucasmartinoia)\
**Post date:** [September 22, 2016, 7:00pm UTC](https://forums.kodeco.com/t/afnetworking-2-0-tutorial/6297/6 "2016-09-22T19:00:19Z")

</div>

Hi skov, I’ve had to adapt the code to use with AFNetworking 3.0 in the method jsonTapped:

- (IBAction)jsonTapped:(id)sender  
{  
// 1  
NSString \*string = [NSString stringWithFormat:@“%@weather.php?format=json”, BaseURLString];  
NSURL \*url = [NSURL URLWithString:string];

I’ll continue doing this great tutorial.

For more information about what has changed between both versions: [here](https://github.com/AFNetworking/AFNetworking/wiki/AFNetworking-3.0-Migration-Guide)

---

<div class="post-metadata">

**Author:** ![skov](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/skov/32/107268_2.png) [@skov](https://forums.kodeco.com/u/skov)\
**Post date:** [September 23, 2016, 5:46pm UTC](https://forums.kodeco.com/t/afnetworking-2-0-tutorial/6297/7 "2016-09-23T17:46:15Z")

</div>

Hey , thanks for your replay, but you updated the AFNetworking 2.0 tutorial instead og my post 😃

---

<div class="post-metadata">

**Author:** ![tikam](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/tikam/32/81494_2.png) [@tikam](https://forums.kodeco.com/u/tikam)\
**Post date:** [June 29, 2017, 7:21am UTC](https://forums.kodeco.com/t/afnetworking-2-0-tutorial/6297/8 "2017-06-29T07:21:53Z")

</div>

[http://www.raywenderlich.com/demos/weather\_sample/weather.php?format=xml](http://www.raywenderlich.com/demos/weather_sample/weather.php?format=xml)

URL is not working

---

<div class="post-metadata">

**Author:** ![shogunkaramazov](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/shogunkaramazov/32/108826_2.png) [@shogunkaramazov](https://forums.kodeco.com/u/shogunkaramazov)\
**Post date:** [November 16, 2017, 3:30pm UTC](https://forums.kodeco.com/t/afnetworking-2-0-tutorial/6297/9 "2017-11-16T15:30:51Z")

</div>

This tutorial is more than six months old so questions are no longer supported at the moment for it. We will update it as soon as possible. Thank you! :]

---

<div class="post-metadata">

**Author:** ![shogunkaramazov](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/shogunkaramazov/32/108826_2.png) [@shogunkaramazov](https://forums.kodeco.com/u/shogunkaramazov)\
**Post date:** [November 16, 2017, 3:30pm UTC](https://forums.kodeco.com/t/afnetworking-2-0-tutorial/6297/10 "2017-11-16T15:30:53Z")

</div>


