On 1 Aug 2009, at 19:30, Development wrote:
I left out a crucial bit of information not realizing it was crucial. I was using the NSURLConnection synchronous request every 4 seconds on the main thread.
Erm, yeah, that'll do it. As a general rule of thumb, you don't want to be doing synchronous network operations from the main thread of your app. In fact, you should only do things synchronously on the main thread if you're sure that the amount of time they'll take is sensibly bounded (under reasonable conditions---e.g. the machine/phone isn't malfunctioning).
I noticed that in some circumstances I had a fairly regular lag spike. Almost timed to exactly 4 seconds, the time span of my ticker. I moved all timed requests to separate threads and the lag is gone.
Why do that? NSURLRequest can act asynchronously already---why not use the asynchronous mode of operation, and then you don't need to create any threads?
The only downside is that you have to write your code (that uses NSURLRequest) in the form of a state machine, but in many ways that's a nice fit for OO---you can easily create an object specifically for that purpose.
Kind regards, Alastair. -- http://alastairs-place.net _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com