AFNetworking vs SDWebimage - afnetworking

I am developing a news app. Get the image and news from the server. I want to use cache to get the old news. And the custom can remove the cache when there is less disk storage.
The NSURLSession seems have bug for cache. So I decided to use AFNetworking or SDWebImage. But I don't know which one is suit for my app.

SDWebImage is very convenient especially with the progressive image download. But it’s based out of NSURLConnection ( even in the latest version 3.7.5 ) and we know that that is deprecated starting iOS 9. NSURLSession has been around for 3+ years now. Surprisingly SDWebImage has still not migrated to NSURLSession.
See the SDWebImage: [Discussion] Migration to NSURLSessions.
AFNetworking 3.0 is completely based on NSURLSession. So I think AfNetworking would a better choice than SDWebImage.

Related

How to receive list of binaries from server in iOS

In my iOS app, I am trying to get a list of serialized objects from an HTTP server.
Which Apple API should I choose to get the binary from server?
I have read about NSURLSession, NSURLConnection, and others, but not sure which one to choose.
Both will do. NSURLSession is much more powerful tool than NSURLConnection.
If your task is simple - use NSURLConnection. If you need all that fine features of NSURLSession - go for it.
There's a great tutorial on using NSURLSession NSURLSession tutorial. It also states diff between both tools
Also, take a look at AFNetworking framework - makes everything much easier

Best practises for uploading video in ios app

I'm developing an ios application.
As part of my application I need to support upload of a small sized video created by the user (20 mb).
What would be the best way to approach the uploading? Should I handle it with a queue? Are there any built in libraries that support it?
Thanks
That depends on the version of iOS you are planning to deploy on. As of iOS 7, the NSURLSession class provide mechanisms to allow you to finish larger file transfers in background and pause them.
Follow the next links for more information:
https://developer.apple.com/library/mac/documentation/cocoa/conceptual/urlloadingsystem/Articles/UsingNSURLSession.html
https://developer.apple.com/library/ios/documentation/Foundation/Reference/NSURLSession_class/Introduction/Introduction.html
http://www.raywenderlich.com/51127/nsurlsession-tutorial
AFNetworking also provides very easy to use API around NSURLSession and it even supports older iOS versions (not their entire API though).
There is also some information in questions below:
How to work with large file uploads in ios?
AFNetworking + big download files + resume downloads
How to Transfer Large Files over wifi in iOS
If iOS7 support is enough for you, I would suggest using AFNetworking 2.0 library and following their best practices described in their extensive documentation at CocoaDocs.
If you do not want to use a library, go with Apple's built in class NSURLSession.
There is a library called AFNetworking.AFNetworking
Learning how to implement look here
Here are some examples

Are there some benefits in using both AFNetworking and ASIHTTPRequest in the application?

I became interested in this after reading the list of libraries used by Instagram:http://instagram.com/about/legal/libraries/
"The following sets forth attribution notices for third party software that may be contained in portions of the Instagram product. We thank the open source community for all of their contributions."
And they list both AFNetworking and ASIHTTPRequest. I don't understand why. Is there some sort of back compatibility or what? As far as I know ASIHTTPRequest is dead for now.
Can someone explain me possible reasons for this? Thanks
As Paul.s pointed in his comment the main reason is legacy code. First version of Instagram app was published in the App Store in 2010. And developing of AFNetworking was started in 2011. So in 2010 the de facto standard for networking code was ASIHTTPRequest and I think Instagram developers choose it. But Instagram is a fastly developed mainstream application with hundred of millions users (2014) which must continuosly update. ASIHTTPRequest is an outdated library for now and AFNetworking is the best library for network bound applications which is a successor of asihttp. I think Instagram developers switched to it fully now and just pointed ASIHTTPRequest in their libraries list because earlier they used it heavily.
AFNetworking is being actively developed by Mattt Thompson. It is state of the art.
Here is the author's note on ASIHTTPRequest:
"Please note that I am no longer working on this library - you may want to consider using something else for new projects. :)"
ASIHTTPRequest uses the CFNetwork framework, which is a lower-level framework than the NSURLConnection framework used by AFNetworking.
This provides a few advantages. One example is the ability to specify an HTTP proxy like so:
NSURL *url = [NSURL URLWithString:#"http://allseeing-i.com/ignore"];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setProxyHost:#"192.168.0.1"];
[request setProxyPort:3128];
It is impossible to specify an HTTP proxy with AFNetworking, because NSURLRequest doesn't support it.
I won't rehash all of the differences, since most of the benefits are outlined in their documentation.
As Zaph notes, ASIHTTPRequest has not been updated in ages. AFNetworking is vastly superior in most respects.
Summary: if you're not sure, use AFNetworking.

Disk Backed Image Cache for UIImageView in AFNetworking

I'm looking to swap out the AFImageCache used by default in the UIImageView+AFNetworking category for something that's disk based and that can managed a little more accurately (something like NSURLCache). Unfortunately, since UIImageView+AFNetworking is a category and not a subclass, I can't just override af_sharedImageCache with a sublclass of UIImageView OR another category.
Is there any other way to achieve this functionality without copying and pasting most of UIImageView+AFNetworking into my own subclass?
The SDWebImage project provides a similar UIImageView category, but offers both in-memory (using NSCache) and on-disk (using NSFileManager) caching. I'd recommend just using that when you need to cache to disk.
The downside to this implementation is that your network requests won't go through your AFHTTPClient subclass, so depending on what your needs are you might need to implement your own operation queue, authentication, etc. If you're just using it for something basic, like displaying avatar images in a table view, it should be fine.
If that downside bothers you, an alternate idea would be to use SDImageCache (included in the SDWebImage project) to cache the images, and download them yourself using AFNetworking.
Finally, note that AFNetworking has built-in support for NSURLCache, and if you create one it will cache your images to disk. However, image caching is typically used for showing lots of images in a UIScrollView, and NSURLCache doesn't have good enough performance for smooth scrolling.
I have a fork of AFNetworking that includes file cache in the NSCachesDirectory.
You can find it here: https://github.com/andyast/AFNetworking_FileCache
There is a branch that is compatible with V1.3.3 if you need that as well.

Is there any iOS library which provides networking as well as disk caching?

I just wanted to know that is there any library which provides networking as well as disk caching both for iOS 4 & above.
I know AFNetworking for networking & SDURLCache & AFCache for disk caching. But I want both support in one.
Any idea pleas help as I am new to iOS development.
Can I use AFNetwork with ARC enabled in iOS5. Will there be any issues for this?
I forgot to mention that I have read this option but as its going away I want to know whether there is any other option
Check ASIHTTPRequest http://allseeing-i.com/ASIHTTPRequest/
Could RestKit be of any help? It let's you integrate stuff online to CoreData.

Resources