↓ Skip to main content

Objective C: I really miss namespaces

·113 words·1 min

One feature that I strongly miss from Objective C are namespaces. Inability to avoid name clash between your  classes sometimes really stands in your way.

I am reading S. Kochan's book "Programming in Objective C" and in one of the examples he creates the class Point. Unfortunately, there already is struct Point defined in mactypes.h.

The solution is easy - rename the darn Point to something like TKPoint ... at least that is what Cocoa naming guide recommends. It is probably matter of getting used to it  - but I still find the solution suggested by Kevin Hoffman much more elegant - too bad it is only theoretical. Much nicer than NSHack ;-)