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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:45:00+00:00 2026-06-17T15:45:00+00:00

I have a dictionary declared, like this, NSString *responseString = [request responseString]; responseDict =

  • 0

I have a dictionary declared, like this,

NSString *responseString = [request responseString];
            responseDict = [responseString JSONValue];
            for (id key in responseDict){
                NSLog(@"%@ : %@", key, [responseDict objectForKey:key]);
            }

Result :

013-01-22 00:14:02.323 PromoTest[2352:c07] A : 0
2013-01-22 00:14:02.325 PromoTest[2352:c07] B : 1
2013-01-22 00:14:02.325 PromoTest[2352:c07] C : 0

now, I want to compare the value and do some operation on it. I presumed the value for a key is of type NSString and compared it to my constant NSString, like this,

NSString *myString1 = @"0";     
NSString *myString2 = [responseDict objectForKey:@"A"];

NSLog(@"%d", (myString1 == myString2)); //1
NSLog(@"%d", [myString1 isEqualToString:myString2]); //1

Result:

2013-01-22 00:19:12.966 PromoTest[2423:c07] 0
2013-01-22 00:19:12.966 PromoTest[2423:c07] 0

Where am i going wrong?? Is my comparison wrong? How do I go about correctly comparing the content??
The data is being received as response data from a web service. I am just converting the data into a dictionary for easily using it. The web service returns a JSON object,

{"A":0,"B":1,"C":0}
  • 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-17T15:45:01+00:00Added an answer on June 17, 2026 at 3:45 pm

    Instead of comparing strings you could also compare number object. here including with a check, if the returned object is a NSNumber, if not, try as string:

    if([responseDict[@"A"] isKindOfClass:[NSNumber class]]){
        NSNumber *myNumber1 = @0;     
        NSNumber *myNumber2 = [responseDict objectForKey:@"A"];
        NSLog("Same number: %@",[myNumber1 isEqualToNumber:myNumber2] ? @"YES" : @"NO");
    
    } else if([responseDict[@"A"] isKindOfClass:[NSString class]]){
        NSString *myString1 = @"0";     
        NSString *myString2 = [responseDict objectForKey:@"A"];
        NSLog("Same string: %@",[myString1 isEqualToString:myString2] ? @"YES" : @"NO");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a dictionary declared like this. public static Dictionary<int?, List<int?>> pegMap = new
I have declared a dictionary like this: Dictionary<string, KeyValuePair<string, string>> dc = new Dictionary<string,
Does VBA have dictionary structure? Like key<>value array?
I have this dictionary mappings declared as a Dictionary<string, HashSet<string>> . I also have
I have code where this is declared: public IDictionary<string, OPTIONS> dict_Options = new Dictionary<string,
I have an ASP DropDown, declared like this: <asp:DropDownList ID=DropDown1 runat=server OnSelectedIndexChanged=DropDown1_SelectedIndexChanged AutoPostBack=true> </asp:DropDownList>
I have dictionary, like Dictionary<string, bool> accValues = new Dictionary<string, bool>() And I want
I have a Dictionary where the key and value are both strings. It's possible
I have a dictionary, user_dict, and create a list for each user value, this
i have this dictionary: a) 2012 UN NEWNW = ( 2012/06/04 Saudi Arabia Huge

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.