Re: how to wait the finish of NSURLDownload
Re: how to wait the finish of NSURLDownload
- Subject: Re: how to wait the finish of NSURLDownload
- From: "Sherm Pendley" <email@hidden>
- Date: Thu, 17 Apr 2008 10:50:24 -0400
On Thu, Apr 17, 2008 at 2:16 AM, xiaobin <email@hidden> wrote:
> hi, all
>
> In my application, I want to download a file from internet. so I use
> NSURLDownload to do it. and using NSRunLoop to wait until finish the
> downloading action. for example 2 seconds. codes as the following
By managing your own runloop, you're making this way harder than it needs to
be. Just open a sheet (or modal panel) with a progress bar, which has its
own runloop. Then make your controller the NSURLDownload object's delegate,
and create a delegate method downloadDidFinish: that closes the sheet/panel.
You can also respond to download:didReceiveDataOfLength: to accurately
update the progress bar.
Delegate methods are key to asynch I/O in Cocoa - it's worthwhile to learn
how to use them.
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.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