Best practice with Notifications on iphone [closed]
开发者_如何转开发
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this questionI'm implementing a system to view the progress of a download in Objective-C, using NSUrlConnetion. Each time that I receive a part of a file I will send a notification by NSNotificationCenter, but with a file of 500-600 KB, how many message will I have? One for each byte or less? Is this a good way or is it too heavy?
The size of the packets that NSURLConnection
receives in the connection:didReceiveData
method vary based on the speed of your connection. I've used NSURLConnection
for downloading files up to 1.5GB and have always had good results updating a progress bar whenever connection:didReceiveData:
is called.
The NSData*
that you'll receive ranges from 2kb to 40kb. For small files you're likely to only get one or two connection:didReceiveData:
calls before connectionDidFinishLoading:
is called.
You will definately have fewer. I'd say that it sounds like a solution that would work.
精彩评论