How to receive list of binaries from server in iOS - 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

Related

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.

Combination of URLRequest +JSON Parsing

What would be the best option for:
URL Request
NSURLConnection
ASIHTTPRequest
AFNetwork
JSON Parsing
NSJSONSerialization
SBJSON
I have picked ASIHTTPRequest+NSJSONSerialization, but I am not quite sure! Any idea(s) or suggestion(s)
Features wise, AFNetworking > ASIHTTPRequest > NSURLConnection. ASIHTTPRequest is not supported anymore. It's a closed project. NSURLConnection is apple-provided so it's barebones. AFNetworking is still an active project and from the talk of my colleagues here in SO, it's getting better.
NSJSONSerialization is Apple-provided and SBJSON is third party again.SBJSON gives your a better/easier interface to convert data objects in either formats (Foundation <--> JSON).
BUT - things majorly depend on what you want to get out of your project and what the requirements are. Each of these projects has it's advantages and disadvantages. You just need to research each of these frameworks and choose the best that suits your project. Also, there are tons of resources here on SO that help you decide what to pick.

Communicate with REST service from ios5 app

I'm building an application that needs to communicate with a REST service.
The application is using ARC so ASIHTTPRequest is NOT an option.
Also RESTKit horribly failed when we tried to use it.
How should we tackle sending the http request? (preferably asynchronicly) and 'storing' the data to be parsed by an XML parser (I don't really need help with that, just need to know how to feed it the data).
You don't need to use ARC everywhere, check out this question and answer, you could just disable ARC for the third party libraries.
Disable Automatic Reference Counting for Some Files
You can use AFNetworking its a very good Lib for REST communication protocol. And you can just disable ARC for AFNetworking as well.

pros of using webservice libraries(RESTKIT/ASIHTTP Request) over NSURLconnection for ios webservices

I would like to understand advantages of using RESTKIT/ASIHTTPREquest libraries over the traditional NSURLconnection for calling RESTFUL/SOAP webservices. I had used both type of webservices(RESTKIT/SOAP) in my project with nsurlconnection and I am successful...
Hence anyone pls help me to understand the benifits of going to RESKIT/ASIhttprequest...
RestKit has good integration with CoreData. ASIHTTP uses blocks which can be nice for firing one off requests. The more I use different network libraries, the more I think there is no one-solution to this problem yet.
Be careful with ASIHTTPRequest. Yeah, it is great and all but it was last updated May 2011 and the author has stopped development on it. See http://allseeing-i.com/%5Brequest_release%5D;

Resources