Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何使用新的 Objective-C 语法在数组中添加新对象。
我知道是这样addObject:,addObjectAtIndex:但我被要求以新的方式来做。
addObject:
addObjectAtIndex:
什么是新方式?
NSMutableArray *mArray = [NSMutableArray new]; mArray[mArray.count] = @"newvalue"; // this can be any object
以上等价于addObject:。
这是您必须阅读的。