Created
August 20, 2014 11:15
-
-
Save mailpraveens/3e3ddee7e2e145a415ed to your computer and use it in GitHub Desktop.
Small snipped to check if a NSString, NSArray or any collection is empty, works for nil objects too.
This file contains 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
static inline BOOL checkIfEmpty(id obj) { | |
return thing == nil || | |
([obj respondsToSelector:@selector(length)] && [(NSData *)obj length] == 0) || | |
([obj respondsToSelector:@selector(count)] && [(NSArray *)obj count] == 0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment