Created
August 2, 2013 13:24
-
-
Save axelrivera/6139844 to your computer and use it in GitHub Desktop.
Function to test empty objects in Objective-C
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 IsEmpty(id thing) { | |
return thing == nil | |
|| thing == [NSNull null] | |
|| ([thing respondsToSelector:@selector(length)] | |
&& [(NSData *)thing length] == 0) | |
|| ([thing respondsToSelector:@selector(count)] | |
&& [(NSArray *)thing count] == 0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment