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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:00:53+00:00 2026-05-28T05:00:53+00:00

I am woundering if I am doing something wrong with this if statement… I

  • 0

I am woundering if I am doing something wrong with this if statement…

I am compairing two indexPaths, and old one and the current selected one if they are not equal I would like to do something other wise continue as normal..

however my if statment is always being accessed even if they are !=.. am I doing something wrong.. I know you can check IsEqual: is here something like that for !=?

heres my code and the output

NSLog(@"%@", modelIndexPath);
            NSLog(@"%@", oldCheckedIndexPath);
            NSLog(@"%@", indexPath);
            if (modelIndexPath != indexPath) {
                NSLog(@"Not Equal");
                NSLog(@" ");
            }

2012-01-19 16:09:06.521 Code[9907:207] (null)
2012-01-19 16:09:06.522 Code[9907:207] (null)
2012-01-19 16:09:06.523 Code[9907:207] <NSIndexPath 0xc2993e0> 2 indexes [9, 0]
2012-01-19 16:09:06.524 Code[9907:207] Not Equal
2012-01-19 16:09:06.525 Code[9907:207]  
2012-01-19 16:09:17.921 Code[9907:207] <NSIndexPath 0xc2993e0> 2 indexes [9, 0]
2012-01-19 16:09:17.922 Code[9907:207] <NSIndexPath 0xc2993e0> 2 indexes [9, 0]
2012-01-19 16:09:17.923 Code[9907:207] <NSIndexPath 0xc5b0c50> 2 indexes [9, 0]
2012-01-19 16:09:17.924 Code[9907:207] Not Equal
2012-01-19 16:09:17.925 Code[9907:207]  
2012-01-19 16:09:29.489 Code[9907:207] <NSIndexPath 0xc5b0c50> 2 indexes [9, 0]
2012-01-19 16:09:29.490 Code[9907:207] <NSIndexPath 0xc5b0c50> 2 indexes [9, 0]
2012-01-19 16:09:29.491 Code[9907:207] <NSIndexPath 0xc7886c0> 2 indexes [9, 2]
2012-01-19 16:09:29.491 Code[9907:207] Not Equal
2012-01-19 16:09:29.492 Code[9907:207]  
2012-01-19 16:09:34.945 Code[9907:207] <NSIndexPath 0xc7886c0> 2 indexes [9, 2]
2012-01-19 16:09:34.946 Code[9907:207] <NSIndexPath 0xc7886c0> 2 indexes [9, 2]
2012-01-19 16:09:34.946 Code[9907:207] <NSIndexPath 0xc89e780> 2 indexes [9, 2]
2012-01-19 16:09:34.947 Code[9907:207] Not Equal
2012-01-19 16:09:34.948 Code[9907:207]  
2012-01-19 16:09:37.601 Code[9907:207] <NSIndexPath 0xc89e780> 2 indexes [9, 2]
2012-01-19 16:09:37.602 Code[9907:207] <NSIndexPath 0xc89e780> 2 indexes [9, 2]
2012-01-19 16:09:37.602 Code[9907:207] <NSIndexPath 0xc94e480> 2 indexes [9, 1]
2012-01-19 16:09:37.603 Code[9907:207] Not Equal
2012-01-19 16:09:37.604 Code[9907:207] 

UPDate:

here is the current state of affairs with the help of you guys

NSLog(@"%@", modelIndexPath);
            NSLog(@"%@", oldCheckedIndexPath);
            NSLog(@"%@", indexPath);

            if ( [modelIndexPath isEqual:indexPath] ) NSLog(@"hurray!");
            if ( ![modelIndexPath isEqual:indexPath] ) NSLog(@"bummer");
            NSLog(@" ");



2012-01-19 16:41:54.853 Code[11071:207] (null)
2012-01-19 16:41:54.854 Code[11071:207] (null)
2012-01-19 16:41:54.855 Code[11071:207] <NSIndexPath 0xc21f9a0> 2 indexes [9, 0]
2012-01-19 16:41:54.856 Code[11071:207] bummer
2012-01-19 16:41:54.856 Code[11071:207]  
2012-01-19 16:41:59.637 Code[11071:207] <NSIndexPath 0xc21f9a0> 2 indexes [9, 0]
2012-01-19 16:41:59.637 Code[11071:207] <NSIndexPath 0xc21f9a0> 2 indexes [9, 0]
2012-01-19 16:41:59.638 Code[11071:207] <NSIndexPath 0x6a73e10> 2 indexes [9, 0]
2012-01-19 16:41:59.639 Code[11071:207] hurray!
2012-01-19 16:41:59.639 Code[11071:207]  
2012-01-19 16:42:05.492 Code[11071:207] <NSIndexPath 0x6a73e10> 2 indexes [9, 0]
2012-01-19 16:42:05.493 Code[11071:207] <NSIndexPath 0x6a73e10> 2 indexes [9, 0]
2012-01-19 16:42:05.494 Code[11071:207] <NSIndexPath 0x6aae9d0> 2 indexes [9, 0]
2012-01-19 16:42:05.494 Code[11071:207] hurray!
2012-01-19 16:42:05.495 Code[11071:207]  
2012-01-19 16:42:10.901 Code[11071:207] <NSIndexPath 0x6aae9d0> 2 indexes [9, 0]
2012-01-19 16:42:10.902 Code[11071:207] <NSIndexPath 0x6aae9d0> 2 indexes [9, 0]
2012-01-19 16:42:10.902 Code[11071:207] <NSIndexPath 0xc625470> 2 indexes [9, 2]
2012-01-19 16:42:10.903 Code[11071:207] bummer
  • 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-28T05:00:53+00:00Added an answer on May 28, 2026 at 5:00 am

    Those NSIndexPath things are objects, and you are comparing their memory addresses. In other words, both modelIndexPath and indexPath are pointers. (google is your friend)

    To compare these objects, use:

    if ( [modelIndexPath isEqual:indexPath] ) NSLog(@"hurray!");
    

    or

    if ( ![modelIndexPath isEqual:indexPath] ) NSLog(@"bummer");
    

    to test for inequality.

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

Sidebar

Related Questions

Am I doing something wrong is this a known issue with the ASP.NET MVC
Just wondering if I am doing something wrong or if this is a perl
I'm just wondering if there's a better way of doing this in SQL Server
I am wondering if there's an elegant solution for doing this in Java (besides
I was wondering if someone could tell me what I am doing wrong that
I was thinking of doing a head request with cURL, was wondering if this
I am wondering if this can be done easily. I am doing some paypal
I'm researching this for a project and I'm wondering what other people are doing
I am wondering if anyone know something about this issue. It seems like the
My question is very similar to this one: Getting an error in jQuery when

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.