{"id":17772,"date":"2017-04-18T11:47:17","date_gmt":"2017-04-18T15:47:17","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=17772"},"modified":"2017-04-20T13:53:48","modified_gmt":"2017-04-20T17:53:48","slug":"avoiding-objective-c-class-name-collisions","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2017\/04\/18\/avoiding-objective-c-class-name-collisions\/","title":{"rendered":"Avoiding Objective-C Class Name Collisions"},"content":{"rendered":"<p><a href=\"http:\/\/penandpapersoftware.com\/blog\/2017-04-14-objc-equivalents-to-swift-solutions-part-1-avoiding-class-name-collisions\/\">Pen &amp; Paper Software<\/a> (<a href=\"https:\/\/news.ycombinator.com\/item?id=14116613\">Hacker News<\/a>):<\/p>\n<blockquote cite=\"http:\/\/penandpapersoftware.com\/blog\/2017-04-14-objc-equivalents-to-swift-solutions-part-1-avoiding-class-name-collisions\/\"><p>But checking every name could get tedious. How about we just look at every prefix-less class name that Apple has used?<\/p><p>[&#8230;]<\/p><p>If we were to use any of those classes, the compiler and linker would\nnot complain. But if you used <code>AppleSpell<\/code> in a video game to\nrepresent the spell an apple casts on your player, and you override\nsome important methods like <code>init<\/code> to do something relevant to your\nown game, you might start seeing very strange behavior!<\/p><p>[&#8230;]<\/p><p>Apple may roll out updates to frameworks <em>between<\/em> OS updates, which I believe has happened before. Ultimately the best solution is to test your app regularly and pay attention to your logs.<\/p><\/blockquote>\n<p>I wonder why Apple doesn&rsquo;t have an internal tool to prevent shipping unprefixed classes.<\/p>\n<p>Update (2017-04-20): See also: <a href=\"https:\/\/developer.apple.com\/library\/content\/documentation\/Cocoa\/Conceptual\/ProgrammingWithObjectiveC\/Conventions\/Conventions.html#\/\/apple_ref\/doc\/uid\/TP40011210-CH10-SW4\">Apple&rsquo;s naming guidelines<\/a> (via <a href=\"https:\/\/twitter.com\/rosyna\/status\/854790764974321664\">Rosyna Keller<\/a>).<\/p>","protected":false},"excerpt":{"rendered":"<p>Pen &amp; Paper Software (Hacker News): But checking every name could get tedious. How about we just look at every prefix-less class name that Apple has used?[&#8230;]If we were to use any of those classes, the compiler and linker would not complain. But if you used AppleSpell in a video game to represent the spell [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"","apple_news_api_id":"","apple_news_api_modified_at":"","apple_news_api_revision":"","apple_news_api_share_url":"","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[69,31,1380,30,1381,54,760,71],"class_list":["post-17772","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-cocoa","tag-ios","tag-ios-10","tag-mac","tag-macos-10-12","tag-objective-c","tag-objective-c-runtime","tag-programming"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/17772","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=17772"}],"version-history":[{"count":2,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/17772\/revisions"}],"predecessor-version":[{"id":17790,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/17772\/revisions\/17790"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=17772"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=17772"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=17772"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}