0

i try to extract only the properties into an array to create a NSPredicate for this. is there a shorter way for this than creating a mutable array and looping through all objects?

NSMutableArray *extractedIDs = [NSMutableArray array];
for (SomeObject *aObject in self.addedSearchResults) {
    [addedIDs addObject:aObject.someProperty];
}

[NSPredicate predicateWithFormat:@"NOT (someOtherProperty IN %@)", addedIDs]

can't find something with google (don't really know how to search this problem)

0

2 Answers 2

1

KVC can help you. Just use:

NSArray* extractedIDs = [self.addedSearchResults valueForKey:@"someProperty"];
Sign up to request clarification or add additional context in comments.

Comments

1

@Mark is right but I think you are looking for:

NSArray* extractedIDs = [self.addedSearchResults valueForKeyPath:@"nameOfSomeObject.nameOfSomeProperty"];

Comments

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.