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?
NSURLRequest
doesn't actually create any connections. It just encapsulates the parameters of the request. NSURLConnection
actually creates the connection to the server and sends the request. Under the covers, NSURLConnection
instances share and reuse TCP connections, according to this answer:
NSURLConnection is run many times
So you should just use NSURLRequest
and NSURLConnection
if their APIs suit you.
Since NSURLConnection
has been deprecated since iOS 9 / macOS 10.11, you should use NSURLSession
.