The simplest way to check NSNull value , nill value, and lenght =0 of object:
How to call inline function:
static inline BOOL IsEmpty(id object)
{
return object == nil
|| ([object respondsToSelector:@selector(length)]
&& [(NSData *) object length] == 0)
|| ([object respondsToSelector:@selector(count)]
&& [(NSArray *) object count] == 0)
|| ([object respondsToSelector:@selector(count)]
&& object == nil)
|| ([object respondsToSelector:@selector(count)]
&& [ object isKindOfClass:[NSNull class]]);
}
How to call inline function:
NSString *str =nil;
if(!(IsEmpty(str)))
{
NSLog(@"The object is not null, nill,");
}
No comments:
Post a Comment