ios - 带有语法糖的初始化数组,调用了哪个初始化方法?

标签 ios objective-c

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/

相关文章:

javascript - 无法在 iOS 模拟器上运行简单的基于 KineticJs 的 Cordova/PhoneGap 应用程序

ios - 我是否以正确的方式集成了 SQL Cipher?

ios - 从对象所在的数组中获取对象的属性

ios - searchBarCancelButtonClicked popToRootViewControllerAnimated

objective-c - GKachievement(游戏中心)正在显示?

iphone - 如何重置或清除 OpenGLES(iPhone) 中的 glVertexAttribPointer 值?

ios - 在 iOS 14 WidgetKit 中获取当前位置

ios - Objective-C - 有没有办法将 UIView 属性作为数组?

ios - "[NSBigMutableString substringWithRange:]: Range {0, 10} out of bounds; string length 9"撤消错误

iphone - 具有多个参数的 performSelectorOnMainThread