I am needing to write a CalDAV client library for the Mac, and I just wanted to make sure on what would be the best way to write it.
I am wondering if I should just use NSURLRequest or should I go to the socket level, or something in between?
My concern about using just NSURLRequest is that a new connection would be made for each call, instead of having 1 open connection that all “requests” go through.
Am I missing something?
Thoughts? Suggestions?
NSURLRequestdoesn’t actually create any connections. It just encapsulates the parameters of the request.NSURLConnectionactually creates the connection to the server and sends the request. Under the covers,NSURLConnectioninstances share and reuse TCP connections, according to this answer:NSURLConnection is run many times
So you should just use
NSURLRequestandNSURLConnectionif their APIs suit you.UPDATE
Since
NSURLConnectionhas been deprecated since iOS 9 / macOS 10.11, you should useNSURLSession.