简单的内联函数(不定期补充)

2016-07-11  本文已影响3人  SincereDu
static inline BOOL DSIsObjNull(id obj)
{
    return obj == nil ||
    ([obj isEqual:[NSNull null]]) ||
    ([obj respondsToSelector:@selector(length)] && [(NSData *)obj length] == 0) ||
    ([obj respondsToSelector:@selector(count)]  && [(NSArray *)obj count] == 0);
}
static inline BOOL DSIsStringNull(NSString *string)
{
    
    if (string == nil)
    {
        return YES;
    }
    
    if (string.length == 0)
    {
        return YES;
    }
    
    if ([string isEqualToString:@"<null>"])
    {
        return YES;
    }
    
    if ([string isEqualToString:@"(null)"])
    {
        return YES;
    }
    
    return NO;
}
上一篇下一篇

猜你喜欢

热点阅读