Any way to tell if my iPhone app is running under the debugger at runtime?-Collection of common programming errors

The method described here worked fine for me

I tested by placing it in -(void)viewDidLoad

- (void)viewDidLoad {
    [super viewDidLoad];

    int mib[4];
    size_t bufSize = 0;
    int local_error = 0;
    struct kinfo_proc kp;

    mib[0] = CTL_KERN;
    mib[1] = KERN_PROC;
    mib[2] = KERN_PROC_PID;
    mib[3] = getpid();

    bufSize = sizeof (kp);
    if ((local_error = sysctl(mib, 4, &kp, &bufSize, NULL, 0)) < 0) {
        label.text = @"Failure calling sysctl";
        return;
    }
    if (kp.kp_proc.p_flag & P_TRACED)
        label.text = @"I am traced";
    else
        label.text = @"I am not traced";
}