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.
是否有任何方法(除了循环)来提取数组中所有对象的特定属性。所以说在一堆人那里。我想将他们所有的名字提取到一个数组中。
键值编码将帮助您:
NSArray *result = [people valueForKey:@"firstname"];
我的问题得到了答案。这就是我们如何快速实现相同目标的方法。
let arraytWithProperties = arrayWithObjects.map{ $0.propertyName }