Skip to content

Instantly share code, notes, and snippets.

@leberwurstsaft
Created September 4, 2013 12:47
Show Gist options
  • Save leberwurstsaft/6436459 to your computer and use it in GitHub Desktop.
Save leberwurstsaft/6436459 to your computer and use it in GitHub Desktop.
Whitespace Check
#import <Foundation/Foundation.h>
@interface NSString (Stuff)
- (BOOL)containsOnlyWhiteSpace;
@end
#import "NSString+Stuff.h"
@implementation NSString (Stuff)
- (BOOL)containsOnlyWhiteSpace {
return ([self stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]].length == 0);
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment