Defining string constants

We need to use some private constants, normally declared in a.m file, or we can define global constants in a.h.

/ / / show the remote push content static nsstrings * const ShowRemoteNotificationContentKey = @ "ShowRemoteNotificationContentKey"; / / / gross margin data refresh the naked car static nsstrings * const RefreshDealerGrossProfitNotificationKey = @"RefreshDealerGrossProfitNotificationKey"; Static NSString * const ReLoginNotificationKey = @"ReLoginNotificationKey"; / / / refresh competing goods price data static nsstrings * const RefreshCompetitivePricesNotificationKey = @"RefreshCompetitivePricesNotificationKey";Copy the code

The normal public way to define string constants is with the extern keyword; #define is not recommended.

Defined in the.h file

/// extern NSString * const QXUserTokenKey; /// user UUID extern NSString * const QXUserUUIDKey; Extern NSString * const QXUserCityKey; /// extern NSString * const QXUserCityKey; Extern NSString * const QXFirstLaunchKey; // Extern NSString * const QXFirstLaunchKey;Copy the code

In my.m file

NSString * const QXUserTokenKey = @"com.qianxx.user.token"; /// NSString * const QXUserTokenKey = @"com.qianxx.user.token"; /// user UUID NSString * const QXUserUUIDKey = @"com.qianxx.user.uuid"; NSString * const QXUserCityKey = @"com.qianxx.user.city"; /// NSString * const QXUserCityKey = @"com.qianxx.user.city"; / / / start the application for the first time nsstrings * const QXFirstLaunchKey = @ "com. Qianxx. User. IsFirstLaunch";Copy the code