2

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];

1 Answer 1

2

Yeah that feature already exists:

NSArray *locationProperty = [carparkArr valueForKey:@"locationCoord"];
Sign up to request clarification or add additional context in comments.

3 Comments

Is that CLLocationCoordinate is a structure isn't a problem? NSArray cannot handle not NSObject elements.
@Szu KVC will wrap it automatically within an NSValue or NSNumber object.
Thanks. I didn't think Foundation framework is so smart!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.