How to read an image from disk and block until its read?

Posted by Shizam on Stack Overflow See other posts from Stack Overflow or by Shizam
Published on 2010-04-14T15:19:10Z Indexed on 2010/04/14 15:23 UTC
Read the original article Hit count: 241

Filed under:
|
|
|
|

I'm loading 5 images from disk but I want the 1st image I read to show as soon as possible. Right now I do

UIImage *img = [UIImage imageWithContentsOfFile:path];

in a for loop but since imageWithContentsOfFile:path isn't blocking all 5 images wind up getting read from disk before the first one will appear (because they're all using up I/O). I confirmed this by just load one and it appeared on screen faster than if I load all 5.

I'd like to load the 1st image and block until its fully read and shown before loading the next 4 or load the 1st one and be notified when its done before loading the next 4 but I can't figure out a way to do it. None of the 'WithContentsOfFile' methods for data or image block and they don't notify or have delegate methods. Any suggestions?

Thanks

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about iphone