Create a NSSet from NSArray based on property

前端 未结 5 1743
礼貌的吻别
礼貌的吻别 2021-01-12 04:22

How does one create a NSSet of objects from an array based on a property.

e.g. Array of objects, each with a strong reference to a type pro

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-12 04:56

    NSSet *distinctSet = [NSSet setWithArray:[array valueForKeyPath:@"@distinctUnionOfObjects.property"]];
    

提交回复
热议问题