Re: How to update table while in a method
Re: How to update table while in a method
- Subject: Re: How to update table while in a method
- From: Graham Cox <email@hidden>
- Date: Fri, 13 Nov 2009 18:53:40 +1100
On 13/11/2009, at 6:20 PM, Ashley Perrien wrote:
> But it seems that the table refuses to redraw until after everything has been updated. So when I do this process, I get the spinning cursor for a few second (looks like it hung) and then the table updates. I'd prefer the table to update as information comes in. Note that I'm not using any bindings in this.
The redraw is done once per event loop. Since in your simple loop the event loop isn't being run, you don't see anything happen. Naive loops like this are useless for lengthy tasks that depend on some external resource like a server, which might not return anything at all - in which case you've just hung your app.
> I tried spinning off the table update into a new NSOperationQueue and that didn't help so I'm assuming spinning the resource update to another queue also wouldn't help either. Any suggestions?
I'm assuming [resource updateInfo] does something network-y to get information from the web? In which case that should be handled asynchronously. As each result comes in you can call reloadData on the table. Asynchronous handling of the internet doesn't require a separate thread - I believe NSURLConnection does its thing as part of the normal run loop. But if it were on a thread, the table update would have to be called on the main thread, as it's an interface object, i.e. using -performSelectorOnMainThread:waitUntilDone:
The documentation and companion guides for NSURLConnection should get you started.
--Graham
_______________________________________________
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