Last active
December 21, 2015 04:19
-
-
Save ScottEAdams/6248273 to your computer and use it in GitHub Desktop.
NSObject category based on wil shipleys classic isEmpty code. very handy.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "NSObject+IsEmpty.h" | |
@implementation NSObject (IsEmpty) | |
- (BOOL)isEmpty | |
{ | |
return self == nil | |
|| (self == [NSNull null]) | |
|| ([self respondsToSelector:@selector(length)] | |
&& [(NSData *) self length] == 0) | |
|| ([self respondsToSelector:@selector(count)] | |
&& [(NSArray *) self count] == 0); | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment