ios - Should I compare NSNotFound to NSInteger or NSUInteger? -


here's code:

nsarray *allids = [self.purchasableobjects valueforkey:@"productidentifier"]; nsinteger index = [allids indexofobject:productid];  if (index == nsnotfound)     return; 

which 1 compare nsnotfound... nsinteger or nsuinteger , why?

you should use nsuinteger

the reason behind "the array index not going minus (i.e object @ index -5)"

typedef int nsinteger; typedef unsigned int nsuinteger; 

nsinteger must used when there probability values in plus or minus.

hope helps. thanks


Comments