ios - isEqual: and isKindOfClass: - Which is faster? -


For various reasons, to keep order indexed with other things, I have [NSNull null] Inside the array. Like this:

NSArray * arr = @ [obj1, obj2, obj3, [NSUAL tap], Ojavi 4];

In two ways I am thinking of using the code again to ignore the value of the null value, But I'm not sure which is fast. (For <[NSNull null] isEqual: obj]

Method 1

  {id obj} / (for arr in obj } {If ([obj isKindOfClass: / [link]}  

method 2

  MyObject class]]) / Do stiff}}  

My question is this: Since I am running through this array to handle a tiled scroll view in a proper manner (hence executed it several times The user is going to scroll and it is important that it runs as soon as possible), which of these One of the best methods is fast?

[NSNull null] is a singleton, so the easiest thing to do is whether the object pointer is the same or not.

If you really want to be fast, do this:

  (OBG in IR) (if ([NSUUL tap]! = OBJ) {// do stu}}  

But it is unlikely that you can get a visual interface Look at the difference, because we know about a very small difference are talking.

An option discussed in the comments [NSNull null] to accelerate the investigation of a local variable, but it is possible that the compiler does it for you, so I'm just putting it here for reference:

  NSObject * null_obj = [NSNull null]; For (obj in id) arr. (If (null_obj! = Obj) {// Do stuff}}  

Comments

Popular posts from this blog

winforms - C# Form - Property Change -

javascript - amcharts makechart not working -

java - Algorithm negotiation fail SSH in Jenkins -