Ser Pounce
Ser Pounce

Reputation: 14571

Proper Naming Convention for Cocoa Base Classes

I have an app where I subclass UIViewController and add some characteristics to it, then use it for every viewcontroller within my app. I was just wondering what is the naming convention for this? I've called it UIDefaultViewController, but I was wondering if there is someway I can also name it UIViewController, or if there is a proper naming convention for this? I also have my own implementations of UITextView and some other common UI classes and was just wondering how to name them when they're the primary version of their parent class that I'm using within my app.

Upvotes: 2

Views: 1273

Answers (2)

rosslebeau
rosslebeau

Reputation: 1283

This is fairly common, I think. I do it a lot in my apps, I always call it BaseViewController. For UITextView and such, I think BaseTextView or something makes sense. It's really up to you and what you feel describes it well. I call it a "Base" because you subclass all of your other view controllers from this.

I wouldn't call it UIDefaultViewController because the UI prefix means it is a part of the SDK. I would prefer something like DefaultUIViewController over that.

Upvotes: 2

Catfish_Man
Catfish_Man

Reputation: 41821

You should definitely not use the "UI" prefix. It's reserved for classes from UIKit.framework. I would suggest coming up with your own prefix (initials, company initials, something like that) and using that instead. So I might have CFMViewController, say.

Upvotes: 5

Related Questions