开发者

NSURLConnection performance

开发者 https://www.devze.com 2022-12-21 02:52 出处:网络
I\'m using NSURLConnection for downloading some images in my app currently. Before implementing via this, I implemented it by NSData(dataWithContentOfURL) in NSThread.

I'm using NSURLConnection for downloading some images in my app currently. Before implementing via this, I implemented it by NSData(dataWithContentOfURL) in NSThread. But I wanted to cancel during downloading images, So I changed it to NSURLConnection.

But It happens other problem. Performance was ve开发者_如何学Pythonry low after changing. For example, There is at least 5seconds for downloading images at NSThread(NSData async) But, There is more than 2 or 3 times than it at NSURLConnection(async) !!

Can I enhance performance ?? How??

(* sorry about my question with NSData(dataWithContentOfFile). correct question is dataWithContentOfURL)


(I'm guessing you're reading a local file, since you mentioned your first solution used dataWithContentsOfFile:?)

NSFileHandle's readToEndOfFileInBackgroundAndNotify is probably faster than NSURLConnection for reading a local file asynchronously.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号