views:

68

answers:

1

I track user activity in my iPhone app by having certain user actions call an almost empty Web page that the app does nothing with. Rather, attached to the URL are some querystring paramaters that tell me who's doing something and what it is (after I analyze the logs, that is).

I don't want launching the URL to slow down the app, so I prefer not to wait at all for any response. So after getting a bunch of device info and user action info and attaching that to a querystring, I call:

NSURLRequest *oRequest = [NSURLRequest requestWithURL: oURL cachePolicy: (etc) timeoutInterval: 2.0];
NSURLConnection *oConnection = [[NSURLConnection alloc] initWithRequest:oRequest delegate: self];

Is this the fastest way to create a Web log entry while hindering my app the least?

+2  A: 

You might put your request in the background by wrapping it in a selector and calling -performSelectorInBackground:withObject:. Or do the same within a one-off NSInvocationOperation.

This doesn't speed up the communication between the phone and the server, but it does put the request on a background thread, so that your app's user can keep doing whatever she is doing mostly unimpeded.

Alex Reynolds