Jimmy
Jimmy

Reputation: 10341

Objective-C Class Prefix for a library APIs

Lets say I'm creating an SDK for a company called "MyCompany" and its a unique company name. All the library classes are prefixed with "MC" only the main API library class "MyCompany.h" is not. Is this appropriate or should I also prefix that class too?

Upvotes: 0

Views: 386

Answers (3)

frankfle
frankfle

Reputation: 101

I think that's appropriate. To make sure, I'd download some popular SDKs, and see what they do. Like Facebook, and others like that.

Also, note that technically, your class prefixes should be at least 3 characters, unless you're Apple. Per Apple. Although, I don't think a lot of people use that guideline.

Edit: I edited this because I didn't like my first answer...

Upvotes: 2

bbum
bbum

Reputation: 162722

MyCompany.h does not -- should not -- define any linkable symbols. It should only #import the rest of your framework's/library's headers.

Thus, there is no conflict because there are no actual unprefixed symbols defined; there should not be a MyCompany class, for example.

Upvotes: 2

Ben S
Ben S

Reputation: 69382

Your proposed naming scheme matches what Apple does as well as what many third-party libraries do.

I think that sounds like a reasonable way to name your library.

Upvotes: 0

Related Questions