There isn't, as others have already said, such a thing as a private method in Objective-C. However, starting in Objective-C 2.0 (meaning Mac OS X Leopard, iPhone OS 2.0, and later) you can create a category with an empty name (i.e. @interface MyClass ()
) called Class Extension. What's unique about a class extension is that the method implementations must go in the same @implementation MyClass
as the public methods. So I structure my classes like this:
In the .h file:
@interface MyClass {
// My Instance Variables
}
- (void)myPublicMethod;
@end
And in the .m file:
@interface MyClass()
- (void)myPrivateMethod;
@end
@implementation MyClass
- (void)myPublicMethod {
// Implementation goes here
}
- (void)myPrivateMethod {
// Implementation goes here
}
@end
I think the greatest advantage of this approach is that it allows you to group your method implementations by functionality, not by the (sometimes arbitrary) public/private distinction.
You should create a header file like
// Constants.h
FOUNDATION_EXPORT NSString *const MyFirstConstant;
FOUNDATION_EXPORT NSString *const MySecondConstant;
//etc.
(you can use extern
instead of FOUNDATION_EXPORT
if your code will not be used in mixed C/C++ environments or on other platforms)
You can include this file in each file that uses the constants or in the pre-compiled header for the project.
You define these constants in a .m file like
// Constants.m
NSString *const MyFirstConstant = @"FirstConstant";
NSString *const MySecondConstant = @"SecondConstant";
Constants.m should be added to your application/framework's target so that it is linked in to the final product.
The advantage of using string constants instead of #define
'd constants is that you can test for equality using pointer comparison (stringInstance == MyFirstConstant
) which is much faster than string comparison ([stringInstance isEqualToString:MyFirstConstant]
) (and easier to read, IMO).
Best Answer
I don't think any of the other answers concisely answers the question.
CFBundleDisplayName
- displayed: below icon. According to docs, should be localized, but only if the app itself is localized, otherwise there will be some kind of penalty (if this is true in reality I cannot say)CFBundleName
- displayed: I have no idea. Docs suggest that it will be used in lists thus recommended max 16 characters, but for instance the Settings→General→Usage list of apps usesCFBundleDisplayName
really. To date I have never figured out where exactly this one is used.Oh, this is for iOS apps, can't speak for other OSes.