Your location:Tech News>News>Script>Solution IOS developed an empty string

Latest News

Solution IOS developed an empty string

Author:fsadmin

Views:

  - (Boolean) isEmptyOrNull: (NSString *) str {

  if (!str) {

  // null object

  return true;

  } Else if (str == Null) {

  return true;

  } Else if ([str isKindOfClass: [NSNull class]]) {

  return true;

  } Else {

  NSString * trimedString = [str stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]];

  if ([trimedString length] == 0) {

  // empty string

  return true;

  } Else {

  // is neither empty nor null

  return false;

  }

  }

  }

Recommend article

Relate article