You can iterate over each character in a line and check if it is a space character (") or a new line (" \ n "). If not, return false. If you scan the entire line and do not return false, it is" empty ".
Something like that:
NSString* myStr = @"A STRING";
for(int i = 0; i < [myStr length]; i++)
{
if(!(([myStr characterAtIndex:i] == @' ') || ([myStr characterAtIndex:i] == @'\n')))
{
return false;
}
}
source
share