ios - NSArray indexOfObject returning nil -
any idea why can't index of object i'm sure exist in array? instead, i'm getting nil..
(lldb) po newitem <receiptitem: 0x16a428b0> (lldb) po self.items <__nsarraym 0x169bf0e0>( <receiptitem: 0x16a428b0> ) (lldb) po [self.items indexofobject:newitem] <nil>
thanks
-indexofobject:
returns integer of type nsuinteger
, not object reference. therefore should not use po
(print object) debugger command, p
.
it returns 0
, not nil
, means found object @ first position of array. if not find object, -indexofobject:
return nsnotfound
.
the lowest index corresponding array value equal anobject. if none of objects in array equal anobject, returns nsnotfound.
Comments
Post a Comment