Re: IPhone Textview question
Re: IPhone Textview question
- Subject: Re: IPhone Textview question
- From: Alastair Houghton <email@hidden>
- Date: Sun, 2 Aug 2009 11:45:25 +0100
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 (email@hidden)
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:
This email sent to email@hidden