Objective c: Check if integer/int/number

前端 未结 6 2124
不知归路
不知归路 2021-02-13 02:25

In objective c, how can i check if a string/NSNumber is an integer or int

6条回答
  •  北海茫月
    2021-02-13 03:02

    I've put this in my category NSString (Util).

    - (BOOL) isInt {
        if ([self isEqualToString:@"0"])
            return YES;
        return (self.intValue != 0);
    }
    

提交回复
热议问题