现在的位置: 首页 > 综合 > 正文

Error about updating UI in background thread

2012年08月24日 ⁄ 综合 ⁄ 共 489字 ⁄ 字号 评论关闭

How to fix the following error "bool _WebTryThreadLock(bool), 0xxxxxx: 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..."?

Cause: update ui in background thread.

Solution: update ui in main thread.

Generic use:

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        // Do time-consuming task in background thread
	// Return back to main thread to update UI
        dispatch_sync(dispatch_get_main_queue(), ^{
            // Update UI
        });
    });

 

 


 

抱歉!评论已关闭.