{"id":4829,"date":"2014-03-30T15:43:55","date_gmt":"2014-03-30T15:43:55","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/calling-selectors-in-mm-but-not-in-h-file-collection-of-common-programming-errors\/"},"modified":"2014-03-30T15:43:55","modified_gmt":"2014-03-30T15:43:55","slug":"calling-selectors-in-mm-but-not-in-h-file-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/calling-selectors-in-mm-but-not-in-h-file-collection-of-common-programming-errors\/","title":{"rendered":"calling selectors in .mm but not in .h file-Collection of common programming errors"},"content":{"rendered":"<p>I wanted to check my understanding of what&#8217;s going in this example regarding selectors:<\/p>\n<p>Suppose I have an <code>NSArray<\/code> of <code>Foo<\/code> objects called arr in Bar.m. In Foo.m, I have a <code>(NSComparisonResult)compareFoo:<\/code> method, but I forget to declare in the Foo.h file. Yet, when I call <code>[arr sortedArrayUsingSelector:@selector(compareFoo:)];<\/code> the code runs fine. Is this because the message <code>compareFoo:<\/code> is getting sent to the objects in the array, which are <code>Foo<\/code> objects, so they can call <code>compareFoo:<\/code> even if it&#8217;s not declared in Foo.h?<\/p>\n<p>Wasn&#8217;t 100% sure about this and got curious. Thanks!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I wanted to check my understanding of what&#8217;s going in this example regarding selectors: Suppose I have an NSArray of Foo objects called arr in Bar.m. In Foo.m, I have a (NSComparisonResult)compareFoo: method, but I forget to declare in the Foo.h file. Yet, when I call [arr sortedArrayUsingSelector:@selector(compareFoo:)]; the code runs fine. Is this because [&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-4829","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4829","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=4829"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4829\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4829"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4829"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4829"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}