我正在尝试使用这个iOS功能
我相信我已将数组传入其中,但我无法弄清楚如何访问该数组,我不明白如何使用它。我花了几个小时试图解决它...请帮助我!
+ (instancetype)arrayWithObjects:(id)[@"Starcraft", @"League of Legends", @"Starcraft 2", @"World of Warcraft",
@"The Sims", @"Icewind Dale", @"Shadowbane", @"Grand Theft Auto 3", @"Pac Man", @"Astroids",
@"Grand Theft Auto 4", @"Grand Theft Auto 5", @"MineCraft", @"Mass Effect", @"Mass Effect 2",
@"Mass Effect 3", @"Dragon Age", @"The Sims 2", @"The Sims 3", @"Rockband", @"Rockband 2",
@"Rockband 3", @"Dragon Age 2", @"The Witcher", @"The Witcher 2", @"Plants vs Zombies",
nil]
{
return [[[self class] alloc] init];
}
答案 0 :(得分:2)
如果你想要一个完整的对象数组而不是一个包含单个数组的数组,这就是你真正想要的东西。
NSArray* array = [NSArray arrayWithObjects:@"Starcraft", @"League of Legends", @"Starcraft 2", @"World of Warcraft",
@"The Sims", @"Icewind Dale", @"Shadowbane", @"Grand Theft Auto 3", @"Pac Man", @"Astroids",
@"Grand Theft Auto 4", @"Grand Theft Auto 5", @"MineCraft", @"Mass Effect", @"Mass Effect 2",
@"Mass Effect 3", @"Dragon Age", @"The Sims 2", @"The Sims 3", @"Rockband", @"Rockband 2",
@"Rockband 3", @"Dragon Age 2", @"The Witcher", @"The Witcher 2", @"Plants vs Zombies",
nil];
它在给定字符串的运行时创建一个以nil结尾的NSArray,以指示结束。