Tuesday, January 26, 2010

How to Debug Currently Used Thread in iPhone

Sometimes everything you code is correct, just doesn't work all the time. Problem might be that occasionally your UI update related code is called from non-main thread. This is how to debug which thread you're using:

#include <pthread.h>

- (void)myFunction
{
NSLog(@"Thread (%d)",
pthread_mach_thread_np(pthread_self()));
}

1 comment:

  1. Note to myself, don't forget the INCLUDE! Yep, debugging multi-threaded memory management again.

    ReplyDelete