Tuesday, April 18, 2017 [Tweets] [Favorites]

Avoiding Objective-C Class Name Collisions

Pen & 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?

[…]

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 an apple casts on your player, and you override some important methods like init to do something relevant to your own game, you might start seeing very strange behavior!

[…]

Apple may roll out updates to frameworks between OS updates, which I believe has happened before. Ultimately the best solution is to test your app regularly and pay attention to your logs.

I wonder why Apple doesn’t have an internal tool to prevent shipping unprefixed classes.

Update (2017-04-20): See also: Apple’s naming guidelines (via Rosyna Keller).

Comments

Stay up-to-date by subscribing to the Comments RSS Feed for this post.

Leave a Comment