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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:54:54+00:00 2026-06-03T04:54:54+00:00

Absolutely baffling issue where if I try and compare a string in a mutable

  • 0

Absolutely baffling issue where if I try and compare a string in a mutable array from an external plist to a string, identical strings refuse to admit that they are the same. However, if I create the mutable array directly with the string in it, and then attempt a compare, it says they are the same.

An example is probably easier:

NSString *dragDocPath = [documentsDirectory stringByAppendingPathComponent:@"draggable.plist"];

NSMutableArray *dragArray1 = [[NSMutableArray alloc] initWithContentsOfFile:dragDocPath];

NSString *s1 = [dragArray1 objectAtIndex:0]; //This is <string>skip</string> and checked with logging

NSString *s2 = @"skip";


if (s1==s2) {  //do this 
}

else { //do the other important thing 
}

Without fail, it does the latter and refuses to see that s1==s2

However, I then did

 NSMutableArray *dragArray1 = [[NSMutableArray alloc] init];


[dragArray1 addObject:@"skip"];


NSString *s1 = [dragArray1 objectAtIndex:0];

NSString *s2 = @"skip";

and that turned out ok. I’ve noticed this in a previous test project, but assumed i was doing something obviously wrong so left it.

I’m very confused

my plist file is (and they work for every other use i can find for the arrays in them)

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"     "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>

<string>skip</string>




</array>
</plist>

Any help, pointing out obvious flaws etc… would be very appreciated

i should add that I’ve logged it all to the nth degree at each step, with it saying “1st is skip”, “2nd is skip” and “skip is not equal to skip”…

EDIT: Problem solved thanks to answer below. Always always use isEqualToString

eg:
if([s1 isEqualToString:s2]){….

  • 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-03T04:54:55+00:00Added an answer on June 3, 2026 at 4:54 am

    That’s not how you compare strings, you’re actually comparing the pointers (which are different). You should use isEqualToString:

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

Sidebar

Related Questions

I have an absolutely baffling case in front of me. I have two database
I absolutely loved Dive Into Python when I picked up Python. In fact, tutorials
I absolutely love good defender games (e.g. Gemcraft, Protector: reclaiming the throne) as they
I am absolutely and totally new to rails, so the answer is probably very
This is driving me absolutely insane. I know that, to change the formatting of
I have absolutely no idea how to do this, so I'm just gonna go
I have an absolutely positioned div that has a width of 100% with a
My code was working absolutely fine before the launch of iPhone SDK 3.0 ,
I have absolutely no idea why this is happening but the following code seems
I'm absolutely new to JavaScript and would like to modify a textarea of a

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.