Cookies on this site

We would like to use cookies to understand how the site is used and to measure our campaigns. Nothing is set until you choose, and you can change your mind at any time from “Cookie settings” at the foot of every page. Privacy policy

Contact UsContact Us

Resources / Blogs

Cloud & apps

AFNetworking 3.0

With the launch of iOS 7 Apple introduced a new method for networking named NSURLSession. However there exist a better alternative to consider. Let's explore what that is.

· · 1 min read

AFNetworking 3.0

With the launch of iOS 7 Apple introduced a new method for networking named NSURLSession. However there exist a better alternative to consider – The popular third-party library for iOS, OS X, watchOS and tvOS called “AFNetworking”.
The latest library AFNetworking 3.0 not only includes all the great features provided by NSURLSession, but also has a lot of cool new features up its sleeves- like serialization, reachability support, UIKit integration. It supports JSON, XML and pList (Property List). However with the release of AFNetworking 3.0 in iOS 9, Apple decided to remove all support for the NSURLConnection method, which is now deprecated. Therefore if your project was built using NSURLConnection APIs, then it is now advisable to replace them with NSURLSession based APIs.
Today we will use the AFHTTPRequestOperation and see how AFNetworking 3.0 has evolved from its predecessor AFNetworking 2.0.

For AFNetworking 2.0

NSString *string = [NSString stringWithFormat:@"some_URL.json"];
NSURL *url = [NSURL URLWithString:string];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
AFHTTPRequestOperation *myOperation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
[myOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *myOperation, id responseObject)
{
// . . . when request succeeds
}failure:^(AFHTTPRequestOperation *operation, NSError *error)
{
// . . . if something goes wrong
}];
[myOperation start]; //in AFNetworking 2.0 we have to explicitly start the operation

For AFNetworking 3.0

NSURL *URL = [NSURL URLWithString:@"some_URL.json"];
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
[manager GET:URL.absoluteString parameters:nil progress:nil success:^(NSURLSessionTask *task, id responseObject)
{
// . . . when request succeeds
}failure:^(NSURLSessionTask *myOperation, NSError *error)
{
// . . . if something goes wrong
}];

Princeton IT is the leading mobile application development company in USA. Get in touch!

← All articles

Case studies

Cloud Consulting in practice

Client names are withheld. We are happy to share details on a call.

All case studies
  • Delivered

    On-prem → Amazon RDS

    Nonprofit

    Cloud Consulting

    Oracle from on-premises to Amazon RDS for a national nonprofit

    The nonprofit's on-premises Oracle database had become hard to maintain and scale. We planned the move with automated workflows and validation tests, migrated to Amazon RDS for Oracle with minimal disruption and left a repeatable process for future changes.

    • Automated, tested migration
    • Less day-to-day database upkeep
  • Delivered

    600k files, < 3 days

    Document management

    Microsoft

    600,000 documents moved from ImageRight to SharePoint in under three days

    A one-file-at-a-time script would have needed about 22 days of continuous running. We rebuilt the migration around a SQL work queue with parallel uploads, automatic retries and crash recovery, and it finished unattended in under three days.

    • 1,125 → 8,314 files per hour
    • Under 3 days instead of about 22
  • Delivered

    Every change, flagged

    Food manufacturing

    AI Consulting

    Label comparison agent for a national food cooperative

    Compares two versions of a product label, highlights every change, annotates the PDF and returns an audit-ready list of differences. We moved it from Copilot Studio to Azure Functions when the document processing outgrew the low-code platform.

    • Audit-ready differences in one chat turn
    • Rebuilt from low-code to cloud functions

Keep reading

All Cloud & apps articles

Moving an application to the cloud?

Request a migration plan consult. We will scope the move with you and come back with a fixed-scope plan.