Reputation: 18325
Im my AppDelegate.h
I am just defined the constants:
#define XXDefaultFeedbackRecipent @"[email protected]"
#define XXDefaultFeedbackSubject @"Feedback"
What is the right place to define these type of settings? They are not user settings but they do have the possibility of changing from one release to the next.
Upvotes: 0
Views: 168
Reputation: 41
I recommend the approach the other answers have explained. Using extern NSString * const
Avoid #defines for this sort of thing as everywhere you reference it, a new NSString will be allocated. Not a problem if your only referencing it once or twice but far from optimal.
Be careful not to mis-use this. For config values, service endpoints, etc. consider using a plist to store values. It makes editing config values much easier and allows for further flexibility with continuous integration setups, multiple service environments and remote config updates by push notification.
Upvotes: 0
Reputation: 3598
There's no right place but you may either put it in a 'Constants' file (I usually create a class called constants, delete the interface and implementation of the class and keep the files for this purpose), or in the class where you use those defines.
A better way to keep this data, however, is to use the following:
// in your .h file
extern NSString * const XXDefaultFeedbackRecipent;
// in your .m file
NSString * const XXDefaultFeedbackRecipent = @"[email protected]";
p.s. there's a convention about writing #defines that wants you to write the names of your #defines in capital letters with words separated by underscore (e.g. MY_DEFINE). This is to prevent collisions with other stuff in C libraries and other files. Keep this in mind when writing your #defines.
Upvotes: 1
Reputation: 672
You can keep them as constants in your class, and access them via extern in your .h file. I would also recommend using consts, for type safety.
In your .h
extern NSString * const XXDefaultFeedbackRecipent;
extern NSString * const XXDefaultFeedbackSubject;
In your .m
NSString * const XXDefaultFeedbackRecipent = @"[email protected]";
NSString * const XXDefaultFeedbackSubject = @"Feedback";
Upvotes: 0