I would like to send a simple HTTP to a web server in Objective-C.
From what i’ve seen, the most common way is to use the NSURLRequest with NSUrl….
But i have also stumbled upon the CFNetwork Library which can also be used to communicate with web servers. So my question is : what is the difference between the 2 methods and which one should i use ?
I would like to send a simple HTTP to a web server in Objective-C.
Share
CFNetwork is a lower-level C-based library, whereas
NSURLand friends are part of the higher level Foundation framework.Foundation should cater to all your needs for communicating with web servers via HTTP. Notable classes to look at are
NSURL,NURLConnection,NSURLRequest(and it’s mutable friendNSMutableURLRequest).You should be able to build up complex requests, including things like multi-part form requests using Foundation objects and not having to go down into the CFNetwork library.
CFNetwork is useful for when you start to look at creating and managing your own sockets and streams (although, Foundation can do this too).