Created
October 14, 2020 11:02
-
-
Save igor-makarov/3f25ac51e39360060335290ccbd3acc5 to your computer and use it in GitHub Desktop.
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
// Returns true iff the string is non-nil and contains at least one non-whitespace character | |
CG_INLINE BOOL MVNonEmptyString(NSString * _Nullable string) { | |
if([string isKindOfClass:NSAttributedString.class]) { | |
string = ((NSAttributedString*)string).string; | |
} | |
NSCharacterSet *whitespace = [NSCharacterSet whitespaceAndNewlineCharacterSet]; | |
NSUInteger len = string.length; | |
for (NSUInteger i = 0; i < len; i++) { | |
unichar c = [string characterAtIndex:i]; | |
if (![whitespace characterIsMember:c]) { | |
return YES; | |
} | |
} | |
return NO; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment