高洛峰2017-04-17 16:22:33
It can be like this
static NSString const *imgArr[3] = {
@"引导页1",
@"引导页2",
@"引导页3"
};
大家讲道理2017-04-17 16:22:33
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.
天蓬老师2017-04-17 16:22:33
const NSArray * arr = @[@"123",@"456"];
Written like this, it is already a constant array