Skip to content

Instantly share code, notes, and snippets.

@heliang219
Forked from tonyarnold/gist:2010649
Created December 2, 2019 03:48
Show Gist options
  • Select an option

  • Save heliang219/a090c62ce6ea8ff57a6d14433ae1506e to your computer and use it in GitHub Desktop.

Select an option

Save heliang219/a090c62ce6ea8ff57a6d14433ae1506e to your computer and use it in GitHub Desktop.
Exhaustively check if an Objective-C object is "empty"
static inline BOOL CBIsEmpty(id obj) {
return obj == nil
|| (NSNull *)obj == [NSNull null]
|| ([obj respondsToSelector:@selector(length)] && [obj length] == 0)
|| ([obj respondsToSelector:@selector(count)] && [obj count] == 0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment