{"id":5093,"date":"2014-03-30T18:45:32","date_gmt":"2014-03-30T18:45:32","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/nslogsuper-crashing-collection-of-common-programming-errors\/"},"modified":"2014-03-30T18:45:32","modified_gmt":"2014-03-30T18:45:32","slug":"nslogsuper-crashing-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/nslogsuper-crashing-collection-of-common-programming-errors\/","title":{"rendered":"NSLog(@&ldquo;%@&rdquo;,super) crashing-Collection of common programming errors"},"content":{"rendered":"<p><code>super<\/code> is a way to send a message to yourself and invoke the superclass&#8217;s implementation rather than your own. It&#8217;s not a separate object.<\/p>\n<p><code>NSLog<\/code> takes an object as the parameter to <code>%@<\/code>, and the object you mean to pass here is yourself.<\/p>\n<p>Frankly, I&#8217;m surprised the code in question even compiles.<\/p>\n<p>If you want to log your superclass&#8217;s description of yourself rather than your own, then, as Alex Reynolds says, you must use a <code>[super description]<\/code> message for the parameter to <code>NSLog<\/code>. This sends the <code>description<\/code> message to yourself using your superclass&#8217;s implementation, and passes the object that that message returns (the NSString object that is your superclass&#8217;s description of yourself) as the parameter to <code>NSLog<\/code>.<\/p>\n<p>But that&#8217;s probably not necessary. If you have overridden <code>description<\/code>, that implementation can send <code>[super description]<\/code> and integrate that string* into the description string that it creates and returns. If you haven&#8217;t overridden <code>description<\/code>, then a <code>description<\/code> message to <code>self<\/code> will hit the superclass&#8217;s implementation anyway. Either way, pass <code>self<\/code>, not <code>super<\/code>, to your <code>NSLog<\/code> statements.<\/p>\n<p>*There are several ways you could integrate the one string into the other; see the NSString docs for more details.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>super is a way to send a message to yourself and invoke the superclass&#8217;s implementation rather than your own. It&#8217;s not a separate object. NSLog takes an object as the parameter to %@, and the object you mean to pass here is yourself. Frankly, I&#8217;m surprised the code in question even compiles. If you want [&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-5093","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5093","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=5093"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5093\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=5093"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=5093"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=5093"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}