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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:31:36+00:00 2026-05-30T14:31:36+00:00

As someone who has some programming experience it pains me to be asking this

  • 0

As someone who has some programming experience it pains me to be asking this question. I just started playing around with objective-c a few days ago and I am trying to simply add NSNumber objects to an NSDictionary. The problem is, when I add an NSNumber object with a negative value it seems as if it is being added as a string not an NSNumber.

Here is how I am initializing the dictionary:

testDict = [[NSDictionary alloc] initWithObjectsAndKeys:[NSNumber numberWithDouble:-3],@"x",
                                        [NSNumber numberWithDouble:7, @"a",
                                    nil];

I guess I really have two questions, 1.) Is this not how you create an NSNumber object that has a negative value?

2.) When I print out the dictionary I get the following:

NSLog(@"dictionary = %@", self.testDict);

a = 7;
x = "-3";

Why the double quotes around the -3?

  • 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-30T14:31:37+00:00Added an answer on May 30, 2026 at 2:31 pm

    You’re correct, and everything’s fine. That’s just the dictionary -description being misleading.

    To verify, break on the NSLog() and try (warning: typed on iPhone):

    p [testDict objectForKey:@"x"];
    

    It should reveal it to be an NSNumber instance.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How would you explain to someone who has just started programming in Java, what
As someone who has spent around 10 years programming web applications with Adobe's ColdFusion,
I have question on usage java nio and hope someone who has a lot
Quick question, which I think has a very easy solution for someone who has
I know someone who has a one-man company developing applications in Delphi and Pascal.
As someone who is just starting to learn the intricacies of computer debugging, for
I'm someone who writes code just for fun and haven't really delved into it
I'm working with someone who's looking to get back into programming after several years
I've got a real lemon on my hands. I hope someone who has the
I'm working with someone who has a Google AppEngine site with a custom API

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.