0

I have an array that looks like this:

(
        {
        title = "Chris";
        isMale = 1;
        age = 13;
    },
        {
        defaultTitle = "Jessica";
        isMale = 0;
        age = 15;
    }
)

I want to create another array that contains the dictionaries from the original array where the BOOL isMale is Yes, or 1. How can I do this?

1 Answer 1

3

Use a predicate. You can filter an array with the filteredArrayUsingPredicate: method

NSArray *filteredArray = [originalAray filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"isMale == %@",[NSNumber numberWithBool:YES]]];
Sign up to request clarification or add additional context in comments.

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.