0

Doing a project on addressbook kind of app. I need to predicate address book contacts, result looks like this

(
{
AddressKey =     (
);
Email =     (
);
"JobTitle_Name" = "";
"Organisation_Name" = "";
Phone =     (
            {
        phoneNumber = "+919502266633";
        "phone_type" = home;
    },
            {
        phoneNumber = 9703570333;
        "phone_type" = work;
    },
            {
        phoneNumber = 91234512345;
        "phone_type" = iPhone;
    },
            {
        phoneNumber = 91239123;
        "phone_type" = mobile;
    }
);
"first_name" = Raviraja;
imageKey = "";
"last_name" = "";
serialNumberKey = 53;
source = Device;
}
)

Need to predicate the array using phoneNumber key. I tried this one

        NSPredicate *predicate = [NSPredicate predicateWithFormat:@"ANY %K == %@",@"phoneNumber",[NSString stringWithFormat:@"%@",str]];
        NSArray *array = [contactsArray filteredArrayUsingPredicate:predicate];

but not working eventhough phone number is matching.

Help me out guys.

1
  • Note you can replace [NSString stringWithFormat:@"%@",str] simply by str. Commented Apr 7, 2014 at 5:27

1 Answer 1

1

The key path is wrong, it should be

[NSPredicate predicateWithFormat:@"ANY %K == %@",@"Phone.phoneNumber", ...]
Sign up to request clarification or add additional context in comments.

1 Comment

I love u bro.. so simple. Kind of regret, gimme ur mail ID, me nub teach me man

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.