// Bring XBMC to the front ProcessSerialNumber psn; OSErr err; // loop until we find the process LOG(@"Waiting to get process..."); while(procNotFound == (err = GetProcessForPID([mp_task processIdentifier], &psn))) { // wait... [NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.5]]; } if(err) { LOG(@"Error getting PSN: %d", err); } else { LOG(@"Waiting for process to be visible"); // wait for it to be visible while(!IsProcessVisible(&psn)) { // do nothing! [NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.5]]; } LOG(@"Process is visible, making it front"); SetFrontProcess(&psn); }