There are a few available options for defining constants in Objective-C. I will describe the easiest and most convenient way.
The #define statement allows to declare constants and use them in your programs. To use it simply type the code below in the .m file that will be used.
or if you want to create a file that will contain all your constants, create a new header file (e.g. "ConstantsFile.h") and type all your constants. In order to use those constants you need to import "ConstantsFile.h" in your implementation (.m) file as below:
Enjoy
The #define statement allows to declare constants and use them in your programs. To use it simply type the code below in the .m file that will be used.
#define NAME_OF_CONSTANT 12
#define NAME_OF_CONSTANT @"CONST"
or if you want to create a file that will contain all your constants, create a new header file (e.g. "ConstantsFile.h") and type all your constants. In order to use those constants you need to import "ConstantsFile.h" in your implementation (.m) file as below:
#import "ConstantsFile.h"
Enjoy
No comments:
Post a Comment