Skip to content

Instantly share code, notes, and snippets.

@mailpraveens
Created August 20, 2014 11:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mailpraveens/3e3ddee7e2e145a415ed to your computer and use it in GitHub Desktop.
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.
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