Last active
November 25, 2015 07:41
-
-
Save hlung/97adfa8947c22e2286b6 to your computer and use it in GitHub Desktop.
iOS - how to create constants in private and public scope
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ---------------------------------- | |
//declaration in PRIVATE scope (for using only in your class) | |
// ---------------------------------- | |
// declare in .m | |
static const int kTweetMaxCharacters = 140; | |
static NSString * const kHelloString = @"HELLO!"; | |
// ---------------------------------- | |
// declaration in PUBLIC scope (for using in other classes too) | |
// ---------------------------------- | |
// declare in .h | |
extern const int FGTweetMaxCharacters; | |
extern NSString * const FGTweetSentNotificationName; | |
// declare in .m *** Notice there is NO `static`. *** | |
const int FGTweetMaxCharacters = 140; | |
NSString * const FGTweetSentNotificationName = @"FGTweetSentNotificationName"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This was handy--first thing I saw on Google to list the syntax for declaring NSTimeInterval constants. Props.