{"id":5232,"date":"2014-03-30T19:58:23","date_gmt":"2014-03-30T19:58:23","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/any-way-to-tell-if-my-iphone-app-is-running-under-the-debugger-at-runtime-collection-of-common-programming-errors\/"},"modified":"2014-03-30T19:58:23","modified_gmt":"2014-03-30T19:58:23","slug":"any-way-to-tell-if-my-iphone-app-is-running-under-the-debugger-at-runtime-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/any-way-to-tell-if-my-iphone-app-is-running-under-the-debugger-at-runtime-collection-of-common-programming-errors\/","title":{"rendered":"Any way to tell if my iPhone app is running under the debugger at runtime?-Collection of common programming errors"},"content":{"rendered":"<p>The method described here worked fine for me<\/p>\n<p>I tested by placing it in <code>-(void)viewDidLoad<\/code><\/p>\n<pre><code>- (void)viewDidLoad {\n    [super viewDidLoad];\n\n    int mib[4];\n    size_t bufSize = 0;\n    int local_error = 0;\n    struct kinfo_proc kp;\n\n    mib[0] = CTL_KERN;\n    mib[1] = KERN_PROC;\n    mib[2] = KERN_PROC_PID;\n    mib[3] = getpid();\n\n    bufSize = sizeof (kp);\n    if ((local_error = sysctl(mib, 4, &amp;kp, &amp;bufSize, NULL, 0)) &lt; 0) {\n        label.text = @\"Failure calling sysctl\";\n        return;\n    }\n    if (kp.kp_proc.p_flag &amp; P_TRACED)\n        label.text = @\"I am traced\";\n    else\n        label.text = @\"I am not traced\";\n}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The method described here worked fine for me I tested by placing it in -(void)viewDidLoad &#8211; (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, &amp;kp, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5232","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5232","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=5232"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5232\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=5232"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=5232"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=5232"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}