views:

292

answers:

1

Hi all,

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 very 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)

A: 

(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.

tedge
Oh, My mistake... not dataWithContentsOfFile, but dataWithContentsOfURL... i'm sorry...
oksk
If you don't need backwards compatibility with 10.5 Leopard or earlier, Snow Leopard introduced an NSFileHandle constructor that takes an NSURL:http://tinyurl.com/yk4pdbb
tedge