How to avoid “CoreAnimation warning deleted thread with uncommitted CATransaction” if NOT using CoreAnimation

前端 未结 3 753
北恋
北恋 2021-01-06 14:37

Just in the appdelegates, applicationDidBecomeActive. I create and start a thread, this thread waits an asynchronous download and then save data:

 - (void)a         


        
3条回答
  •  死守一世寂寞
    2021-01-06 14:46

    Another way of ensuring any UI drawing occurs on the main thread, as described by Andrew, is using the method performSelectorOnMainThread:withObject:waitUntilDone: or alternatively performSelectorOnMainThread:withObject:waitUntilDone:modes:

    - (void) someMethod
    {
        […]
    
        // Perform all drawing/UI updates on the main thread.
        [self performSelectorOnMainThread:@selector(myCustomDrawing:)
                               withObject:myCustomData
                            waitUntilDone:YES];
    
        […]
    }
    
    - (void) myCustomDrawing:(id)myCustomData
    {
        // Perform any drawing/UI updates here.
    }
    

    For a related post on the difference between dispatch_async() and performSelectorOnMainThread:withObjects:waitUntilDone: see Whats the difference between performSelectorOnMainThread and dispatch_async on main queue?

提交回复
热议问题