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

  • Home
  • SEARCH
  • 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 7127915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T11:05:00+00:00 2026-05-28T11:05:00+00:00

I’m trying to write a predicate to check a specific value in a dictionary

  • 0

I’m trying to write a predicate to check a specific value in a dictionary I have set up.

This dictionary has string versions of “0”, “1”, and “2” as keys which I would like to access.

The predicate I would like to write is:

$player.currencyDictionaries.0.earned > 1000

The problem is that .0 is not allowed. Assuming I cannot easily change how the dictionary stores values (this is in older versions and I’d like to use the same predicate on all versions as it is hosted on a server) is there any way to access the data?

  • 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-28T11:05:01+00:00Added an answer on May 28, 2026 at 11:05 am

    IIRC, you can do this:

    $player.currencyDictionaries[0].earned > 1000
    

    (You might need to do ['0'] to guarantee that the passed value is a string and not a number)

    Note that this syntax ([0]) only works in predicate format strings. It does not work with key paths.

    This syntax is defined under the “Index Expression” section of the Predicate BNF.


    EDIT

    Actually, this won’t work, and here’s why:

    The string "$player.currencyDictionaries[0].earned" will be read and turned into an NSExpression of type NSKeyPathExpression. This means, when it’s evaluated, it’s going to basically take that string and run it through the receiver’s -valueForKeyPath: method. As I mentioned above, the bracket syntax doesn’t work with key paths, and thus this will produce the incorrect answer.

    However, since you know the currencyDictionaries returns an NSDictionary, and since NSDictionary overrides the -valueForKey: method, you can turn the [0] bit into a key path, by turning it into a literal string:

    $player.currencyDictionaries.'0'.earned
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Basically, what I'm trying to create is a page of div tags, each has
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka

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.