Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6614825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:23:08+00:00 2026-05-25T20:23:08+00:00

In short, I am looking for the correct predicate format to index into a

  • 0

In short, I am looking for the correct predicate format to index into a dictionary attribute on an object.

I have an array of myObject instances, each with an attribute CPDictionary(NSMutableDictionary) extAttributes and I am trying to allow filtering based on values in extAttributes. I am defining my predicate as follows

[CPPredicate predicateWithFormat:@"extAttributes[%K] like[c] %@",key,val]

I am not sure what the correct key-path would be for this. Reading the documentation on NSPredicate it would seem that “extAttributes[%k]” might be an index into an array, not a dictionary. I have tried several alternatives and this is the only one that doesn’t error. When inspecting the resulting objects, the expressions in the predicate object appear to be correct. However, it doesn’t have the intended result.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T20:23:09+00:00Added an answer on May 25, 2026 at 8:23 pm

    It looks like you might be confusing array and dictionary references. Just use a key path (dot-separated element names) to refer to nested elements or object properties, conceptually something like this:

    [CPPredicate predicateWithFormat:@"%K like[c] %@", @"extAttributes.myNestedElementName", val];
    

    Then again, I’m not all that familiar with Cappuccino, so I’m not sure if they’ve done something slightly different here, but this is the way it works in Cocoa and Cocoa touch.

    EDIT

    To compute the key dynamically, all you need to do is compose a key path string:

     var keyPath = [CPString stringWithFormat:@"%@.%@", @"extAttributes", key];
    

    You can now create the predicate as follows:

    [CPPredicate predicateWithFormat:@"%K like[c] %@", keyPath, val];
    

    EDIT

    The equivalent code in Cocoa/Cocoa touch would be:

    NSString *keyPath = [NSString stringWithFormat:@"%@.%@", @"extAttributes", key];
    [NSPredicate predicateWithFormat:@"%K like[c] %@", keyPath, val];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking into some possible options for unit testing C++ classes. So, short and
I'm looking into using a CASS -Certified address validation service to correct user-provided street
I have been looking for C# examples to transform a DAG into a Tree.
I'm looking for a way to atomically increment a short, and then return that
In short, I am looking for the implementation of the IAlarmManager. I am interested
I'm looking for a very private source control/hosting solution. Short of hosting my own,
What I mean is, I'm looking for really short code that returns the lower
Where can I find Pentaho Kettle architecture? I'm looking for a short wiki, design
Im looking to group and sort a Generic List<>. I have a list of
I have an array with 250k entities (with a size of 20 bytes) and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.