变量上的 static const 和 const 之间的区别

Difference between static const and const on a variable

有什么区别:

#import <UIKit/UIKit.h>
const static NSString * name;
@interface AppDelegate : UIResponder <UIApplicationDelegate>


@end

和:

#import <UIKit/UIKit.h>
const  NSString * name;
@interface AppDelegate : UIResponder <UIApplicationDelegate>

@end

static表示变量的作用域仅限于本编译单元。没有它,您将无法在两个不同的实现文件(重复符号)中有两个名为 NSString * name 的变量。