{"id":4954,"date":"2014-03-30T17:12:06","date_gmt":"2014-03-30T17:12:06","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/simple-bool-switching-not-working-collection-of-common-programming-errors\/"},"modified":"2014-03-30T17:12:06","modified_gmt":"2014-03-30T17:12:06","slug":"simple-bool-switching-not-working-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/simple-bool-switching-not-working-collection-of-common-programming-errors\/","title":{"rendered":"Simple bool switching not working?-Collection of common programming errors"},"content":{"rendered":"<p>I am flipping the value of a simple BOOL like this:<\/p>\n<pre><code>active = !active;\nNSLog(@\"%@\", active? @\"active\" : @\"not active\");\n<\/code><\/pre>\n<p>I&#8217;ve done this numerous times but right now, for some reason it&#8217;s not working and it&#8217;s really pissing me off. When ever the flow hits here, it always prints &#8220;active&#8221;. It&#8217;s not switching!!<\/p>\n<p>Here&#8217;s my interface:<\/p>\n<pre><code>@interface HeaderView : UIView {\n    UILabel *label;\n    UIButton *button;\n    UIImageView *background;\n    BOOL active;\n    int section;\n\n    __weak id delegate;\n}\n<\/code><\/pre>\n<p>and function where the action is performed:<\/p>\n<pre><code>- (void)actionTUI:(id)sender {\n    active = !active;\n    NSLog(@\"%@\", active? @\"active\" : @\"not active\");\n    UIImage *image = nil;\n    if (active) {\n        image = [UIImage imageNamed:@\"active.png\"];\n    } else {\n        image = [UIImage imageNamed:@\"unactive.png\"];\n    }\n    [button setBackgroundImage:image forState:UIControlStateNormal];\n    [delegate headerView:self toggled:active];\n}\n<\/code><\/pre>\n<p>Thanks<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I am flipping the value of a simple BOOL like this: active = !active; NSLog(@&#8221;%@&#8221;, active? @&#8221;active&#8221; : @&#8221;not active&#8221;); I&#8217;ve done this numerous times but right now, for some reason it&#8217;s not working and it&#8217;s really pissing me off. When ever the flow hits here, it always prints &#8220;active&#8221;. It&#8217;s not switching!! Here&#8217;s my [&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-4954","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4954","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=4954"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4954\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4954"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4954"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4954"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}