Possible Duplicate:
“static const” vs “#define” in C
In Objective-C what is the difference between the following two lines:
#define myInteger 5
static const NSInteger myInteger = 5;
Assume they’re in MyClass.m above the implementation directive.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
is a preprocessor macro. The preprocessor will replace every occurrence of
myIntegerwith5before the compiler is started. It’s not a variable, it’s just sort of an automatic find-and-replace mechanism.This is a "real" variable that is constant (can’t be changed after declaration). Static means that it will be a shared variable across multiple calls to that block.