NSArray *array = @[@1, @2, @3];
现在我得到了一个数组,但是调用了哪个初始化方法?
+ (instancetype)arrayWithObjects:(const ObjectType [])objects count:(NSUInteger)cnt;
+ (instancetype)arrayWithObjects:(ObjectType)firstObj, ... NS_REQUIRES_NIL_TERMINATION;
+ (instancetype)arrayWithArray:(NSArray<ObjectType> *)array;
- (instancetype)initWithObjects:(ObjectType)firstObj, ... NS_REQUIRES_NIL_TERMINATION;
- (instancetype)initWithArray:(NSArray<ObjectType> *)array;
我 Hook 了 upon init 方法,但没有运气;所以我在这里,使用语法糖时究竟调用了哪个方法。
最佳答案
定义here , 数组文字扩展为 +[NSArray arrayWithObjects:count:]
.
关于ios - 带有语法糖的初始化数组,调用了哪个初始化方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38476255/