Skip to content

Instantly share code, notes, and snippets.

@ScottEAdams
Last active December 21, 2015 04:19
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 ScottEAdams/6248273 to your computer and use it in GitHub Desktop.
Save ScottEAdams/6248273 to your computer and use it in GitHub Desktop.
NSObject category based on wil shipleys classic isEmpty code. very handy.
#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