Objective C: equality == and strict equality === -


as javascript programmer has been drummed head use === instead of == ever possible.

as i'm learning objective c, in official documentation, ever see == being used.

my question is, should continue habits of using strict equality in objective c code? necessary javascript? assume strict equality gives slight performance boost, in objective c boost slight make of difference?

it's simple, in objective c, don't have === operator.

you don't use == compare objects, because compares pointer values, not value of objects. so, if want compare 2 strings example, should use:

[stringobject isequal:@"the string"]; 

this compares string value, not pointers. there valid reasons use == operator compare objects. many delegate callbacks have sender object parameter. if implementing multiple tableviews 1 controller, instance, want check tableview calling method:

- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath {   if (tableview == self.firsttableview) {      ...   }     if (tableview == self.secondtableview) {      ...   } ... } 

Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -