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 8345979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:51:38+00:00 2026-06-09T06:51:38+00:00

I need a dictionary of Strings that point to boolean values. I have an

  • 0

I need a dictionary of Strings that point to boolean values.

I have an NSDictionary toolStates that I create like this

NSArray *keys = [NSArray arrayWithObjects:@"X", @"Y", nil];
NSArray *isActive = [NSArray arrayWithObjects:[NSNumber numberWithBool:NO], [NSNumber numberWithBool:YES], nil];
toolStates = [NSDictionary dictionaryWithObjects:isActive forKeys:keys];

elsewhere in my class, I am trying to retrieve and compare the booean value like this

if ([toolStates valueForKey: @"X"] == [NSNumber numberWithBool:NO]) NSLog(@"%s", "X = NO");

I know that both portions of code are running, but I get a “EXC_BAD_ACCESS” error on the if statement with the output:

<Error>: CGAffineTransformInvert: singular matrix.

Is there something wrong with the comparison?

I get the same error when I try this:

[toolStates setValue:[NSNumber numberWithBool:YES] forKey:@"X"];
  • 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-06-09T06:51:39+00:00Added an answer on June 9, 2026 at 6:51 am

    There are a couple problems with what you have written, but neither of them I think are responsible for your immediate issue (see below). Let’s go through a few of the issues.

    1. Your [toolStates setValue:forKey:] can’t work as written because you have an NSDictionary, not NSMutableDictionary.
    2. -valueForKey: returns id (i.e. it’s going to return your NSNumber instance, not a BOOL. As such, your comparison is incorrect. Your == is doing pointer comparison, which is not what you want. (It might work here if NSNumber is optimized to return a singleton from +numberWithBool: but that’s not behavior you should count on.) The correct way to do equality comparison in Objective-C is the -isEqual: method, e.g., if ([[toolStates valueForKey:@"X"] isEqual:[NSNumber numberWithBool:NO]).

    But you are getting EXC_BAD_ACCESS which normally means you are accessing a deallocated object. My suspicion is bolstered by the fact that you are getting an error related to Core Graphics, which has nothing to do with your code (suggesting your garbage pointer is now pointing to something graphics related).

    Are you using ARC? If not, I don’t see you retaining toolStates anywhere. If you aren’t, and you are accessing it after the next turn of the run loop (which it sounds like), then you would expect a crash. If this doesn’t sound right, or you can’t find the problem, try the following:

    1. Run your code through the Xcode static analyzer (Clang). Fix any warnings it throws at you.
    2. Run your code with zombies enabled, and watch for a “message sent to deallocated instance” or something to that effect.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple Dictionary(of String, Object) that I need to iterate through and
Everytime the program loads, I need a dictionary to have about 15 values. Right
I need to compare two dictionary values if the types stored are equal, this
I need an XML-serializable dictionary. Actually, I now have two quite different programs that
I have a model that contains a dictionary property. (this has been distilled from
The problem: I have Dictionary<String, String> that I need an alias to, but I
I have a string data which I need to parse into a dictionary object.
I need a dictionary but I also need to store a boolean value about
I have one dictionary I need to save into a plist. The paletteDictionary always
I'm quite a beginner at database design. I have two problems that I'd like

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.