0

I need to create static constants in a class that can be used by other classes that import that class. I'm assuming that enum would be the best way to go since I have seen it been used quite often through out Cocoa classes.

1
  • Why do you refer to them as static? Do you mean in a C++ static sense? Objective-C doesn't have the notion of a static class member. Commented Nov 6, 2009 at 1:14

1 Answer 1

2

It depends on how the type is going to be used. An enum can be a simple way to create some named values, but NSString constants can mesh better with the rest of Cocoa (for instance, this is how all the attribute keys for NSAttributedString are represented because they're meant to be stored in a dictionary).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.