IOS determines whether a string has a space instance

  • 2020-09-28 09:09:49
  • OfStack

The following is a self-encapsulated method that can be returned based on the bool Value judgment

The sample code


-(BOOL)isEmpty:(NSString *) str {
  NSRange range = [str rangeOfString:@" "];
  if (range.location != NSNotFound) {
    return YES; //yes Represents contains Spaces 
  }else {
    return NO; // And vice 
  }
}

summary

Above is the whole content of this article, hope to have 1 definite help to everybody's development and study, if have a question, everybody can leave a message to communicate.


Related articles: