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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:05:20+00:00 2026-06-01T16:05:20+00:00

How can I find value differences between two objects of same type. For-example I

  • 0

How can I find value differences between two objects of same type. For-example I have a Rectangle class having x, y, width, height properties and two objects of rectangle class. How can I find(either programmatically or any visualization tool or library etc) which properties of one rectangle differ from second rectangle?

Or is there any way of getting object state on console or to a file?

  • 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-01T16:05:21+00:00Added an answer on June 1, 2026 at 4:05 pm

    The other answers are just fine if you actually know the class of your objects at compile time. If not this is the case you are still lucky because Objective C allows you to explore the instance variables of your object at runtime. A pseudo-code of comparing two unknown object could be:

    + (BOOL) compareObject:(id)obj1 withObject:(id)obj2 {
    
      unsigned int varCount1, varCount2;
      if ([obj1 class] != [obj2 class]) return NO;
    
      Ivar *vars1 = class_copyIvarList([obj1 class], &varCount1);
      Ivar *vars2 = class_copyIvarList([obj2 class], &varCount2);
      BOOL match = YES;
    
      for (int i = 0; i < varCount1; i++) {
        Ivar var1 = vars1[i];
    
        for (int j = 0; i < varCount2; j++) {
          Ivar var2 = vars2[j];
            if (strcmp(ivar_getName(var1), ivar_getName(var2)) == 0) {
              if (object_getIvar(obj1, var1) != object_getIvar(obj2, var2)) {
                match = NO;
                break;
              }
            } 
        }
    
        if (!match) break;
    
      }
    
      free(vars1);
      free(vars2);
    
      return match;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is string a value type or a reference type? I just can't find a
How can I receive a string value, find an Entity with the same name
How can i directly find the number of elements between any two iterator pointing
How can I find the difference between two SQL timestamp values in minutes and
How can I find all column values in a column which have trailing spaces?
I need to find the number of days between two dates : one is
I'm trying to find a good way to maintain PHP configuration differences between a
I have to sort a number of integers, which can have values between 30.000.000
I need to find to the time difference between two values, but the values
I cannot seem to find any straight and clear documentation explaining the differences between

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.