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.
精彩评论