I have an relatively image in local storage, I want to show it to the user without disturbing UI thread. I'm currently using
[[UIImage alloc] initWithContentsOfFile:path];
to load image.
Any suggestions/help please....
I have an relatively image in local storage, I want to show it to the user without disturbing UI thread. I'm currently using
[[UIImage alloc] initWithContentsOfFile:path];
to load image.
Any suggestions/help please....
If all you're trying to do is keep the UI thread available, set up a short method to load it in the background and update the imageView when done:
This presumes
myImageView
is a member variable of the class. Now, simply run it in the background from any thread:Note, in
backgroundLoadImageFromPath
you need to wait until thesetImage:
selector finishes, otherwise the background thread's autorelease pool may deallocate the image before thesetImage:
method can retain it.You can use NSInvocationOperation for this purpose: Call
Where: