views:

272

answers:

1

Hi, I have developed an application which has retrieved the information from remote location...so i put those in UITableView's Section.In response, i will be getting images also..for this i put the background process(only for images..because the app will take more time to retrieve images than text based information..).It is working fine...But if i scroll the tableview while loading the images..it is going to be crashed....

crash Log:

Tried to obtain the web lock from a thread other than the main thread or the web thread. This may be a result of calling to UIKit from a secondary thread. Crashing now...

could anyone has the solution for this..please let me know..how to resolve this crash...Even i used NSThread class for this.. but i didn't get the solution...

Thanks,

Srinivas G

+1  A: 

Maybe you "call to UIKit from a secondary thread". What's the code you use for background image loading? You should display a placeholder image before you get the real data, then notify the main thread (using performSelectorOnMainThread:withObject:waitUntilDone:) when you've finished downloading the image. Your main thread method should be responsible for all the drawing (the tableview, in this case).

Graham Lee
Hi Grahem, Thank u for your valuable response, I used (performSelectorInBackground:withObject:) ,If i used (performSelectorOnMainThread:withObject:waitUntilDone:) it is taking much time to display the view...(performance degradation..after loading all images only..it is going to be display..I dont want to do like this...because of the performance degradation.),Instead of (performSelectorInBackground:withObject:),i used NSThread object to call that method,which is for retrieving the images..after finished the loading images,i just stop the thread object.so the problem is not yet resolved....
Srinivas G
@Srinivas the point is that you can't use any view API on threads except the main thread. So it's fine to download the image data on a background thread, but you _need_ to signal the main thread to do any drawing. As long as you can factor those to parts of the behaviour (data fetching, updating the view) apart then you shouldn't see any bad performance on the UI thread.
Graham Lee
Thank you,now my app is working fine....
Srinivas G