Szu
Szu

Reputation: 2252

Create NSArray with specific property

I have an NSArray called carparkArr that contain MyCarpark objects. This class contain:

@property (nonatomic, assign) CLLocationCoordinate locationCoord;

Now I want to create an array that will have NSValue of each of these objects. How to do it quickly? I want something like:

NSArray *carparkArr = // fetching data
NSArray *locationProperty = [self getArrayForPropertyPath:@".locationCoord" forArray:carparkArr];

Upvotes: 2

Views: 56

Answers (1)

Droppy
Droppy

Reputation: 9731

Yeah that feature already exists:

NSArray *locationProperty = [carparkArr valueForKey:@"locationCoord"];

Upvotes: 2

Related Questions