It involves runtime. Except for the NSString type, it is not allowed to declare a ‘static global constant type OC object’ outside a method. The static const NSArray *imgArr you declared does not know the type of imgArr when 'compiling'. PS: A constant of global constant type, static const is a constant that the system needs to determine when compiling. What type is it? However, the type of OC object is determined at 'runtime'. Different from the determination time of basic data types, it is pushed from compilation time to runtime (the reason why OC supports polymorphism). Except for NSString, NSString is a special data type with special storage structure and permissions to ensure that the system can recognize it. If you want to understand it more deeply, you need to learn the runtime mechanism of OC.
It can be like this
It involves runtime.
Except for the NSString type, it is not allowed to declare a ‘static global constant type OC object’ outside a method.
The static const NSArray *imgArr you declared does not know the type of imgArr when 'compiling'. PS: A constant of global constant type, static const is a constant that the system needs to determine when compiling. What type is it? However, the type of OC object is determined at 'runtime'. Different from the determination time of basic data types, it is pushed from compilation time to runtime (the reason why OC supports polymorphism).
Except for NSString, NSString is a special data type with special storage structure and permissions to ensure that the system can recognize it.
If you want to understand it more deeply, you need to learn the runtime mechanism of OC.
const NSArray * arr = @[@"123",@"456"];
Written like this, it is already a constant array