extracting properties from NSArray of objects

前端 未结 2 1045
一个人的身影
一个人的身影 2021-02-18 18:05

Is there any of way (other than looping) of extracting a particular property of all objects in an array. So say there in an array of people. I want to extract all their first na

相关标签:
2条回答
  • 2021-02-18 18:18

    I got answer for my question. This is how we can achieve the same in swift.

    let arraytWithProperties = arrayWithObjects.map{ $0.propertyName }
    
    0 讨论(0)
  • 2021-02-18 18:38

    Key Value coding will help you with that:

    NSArray *result = [people valueForKey:@"firstname"];
    
    0 讨论(0)
提交回复
热议问题