views:

176

answers:

2

According to Apple, two to three letter prefixes should be used

when naming classes, protocols, functions, constants, and typedef structures.

Does this include classes which are not intended to be part of a framework, simply used internally in an application? I realize this is relying on other developers that develop frameworks you might be using to use prefixes, but that seems acceptable. What about Core Data entities? If I generate classes from them, shouldn't they be prefixed as well?

+6  A: 

To be safe, use a prefix for all classes in your application. All classes are loaded into a single flat namespace in Objective-C and the prefix prevents collisions both now and in the future.

This also includes CoreData entities; they should also use the same prefix as the rest of your application's classes.

bbum
Thanks for clarifying about the CoreData entities. I will say namespaces are one of the things I miss when writing Objective-C.
Don
bbum
+1  A: 

Also note that you may decide some of this code could be used elsewhere, so using prefixes now will safeguard you from potential collisions in the future.

Daniel Tull