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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:08:55+00:00 2026-06-15T13:08:55+00:00

Possible Duplicate: If a == b is false when comparing two NSString objects? Simple

  • 0

Possible Duplicate:
If “a == b” is false when comparing two NSString objects?

Simple Question of comparing 2 strings:

if (string1 == string2)
{
    NSLog(@"it is equal!");
}

thats it but it wont work for me it is always !=
i testet it with string2 = string1; but it wont work.

so i tested if (string1 isEqualToString:string2) but in that case there is a syntax error

Thanks for any help!

Regards Curtis

  • 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-15T13:08:57+00:00Added an answer on June 15, 2026 at 1:08 pm

    == compares the address of the objects, not their content. Two different objects will obviously never have the same address.

    To compare strings use NSString‘s isEqualToString: method:

    if ([string1 isEqualToString:string2]) {
        NSLog(@"it is equal");
    }
    

    Note the square brackets [ ]. This is the proper Objective-C syntax for sending messages (i.e. calling functions).

    To generally compare object in regards to their content, use isEqual:.

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

Sidebar

Related Questions

Possible Duplicate: If a == b is false when comparing two NSString objects? In
Possible Duplicate: Comparing two identical strings with == returns false I am having real
Possible Duplicate: comparing two variables returns false result <?php if( 32 is this a
Possible Duplicate: Python '==' vs 'is' comparing strings, 'is' fails sometimes, why? Hi. I
Possible Duplicate: Comparing two collections for equality I need to verify if two IEnumerable<T>
Possible Duplicate: How do you determine equality for two JavaScript objects? Object comparison in
Possible Duplicate: php false place in condition I have noticed that a lot of
Possible Duplicate: GetImageSize() not returning FALSE when it should i currently have a filter
Possible Duplicate: Is there a difference between YES/NO,TRUE/FALSE and true/false in objective-c? I have
Possible Duplicate: Javascript regex returning true.. then false.. then true.. etc var r =

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.