How to declare NSString constants for passing to NSNotificationCenter

后端 未结 6 390
无人及你
无人及你 2020-12-24 02:29

I\'ve got the following in my .h file:

#ifndef _BALANCE_NOTIFICATION
#define _BALANCE NOTIFICATION
const NSString *BalanceUpdateNotification
#endif
         


        
6条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-24 03:05

    NSStrings are immutable, so declaring a const NSString * would be redundant; just use NSString *.

    If what you're trying to do is declare that the pointer itself can't change, that would be:

       NSString * const BalanceUpdateNotification = @"BalanceUpdateNotification";
    

    See also Constants in Objective-C

提交回复
热议问题