Determining Equality of Objects

  If you need to determine whether one object is the same as another object, it’s important to remember that you’re working with pointers. The standard C equality operator == is used to test equality between the values of two variables, like this:

  Determining Equality of Objects

  When dealing with objects, the == operator is used to test whether two separate pointers are pointing to the same object:

  Determining Equality of Objects

  If you need to test whether two objects represent the same data, you need to call a method like isEqual:, available from NSObject:

  Determining Equality of Objects

  If you need to compare whether one object represents a greater or lesser value than another object, you can’t use the standard C comparison operators > and <. Instead, the basic Foundation types, like NSNumber, NSString and NSDate, provide a compare: method:

  Determining Equality of Objects

  

相关文章:

  • 2021-12-02
  • 2021-08-20
  • 2022-12-23
  • 2022-12-23
  • 2021-09-30
  • 2022-01-25
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-06-13
  • 2021-12-26
  • 2021-06-03
  • 2022-12-23
  • 2022-03-09
  • 2021-08-26
  • 2022-12-23
相关资源
相似解决方案