0

In order to compare the string of 2 nodes, the text input is

if ([node.name isEqualToString: otherNode.name]) {
}

I am trying to find something like that except instead of comparing it, I want to find out if the string has a value of NULL.

if ([node.name isEqualToString:NULL]){
}

Any help?

Wei Pan
  • 57
  • 7

1 Answers1

1

The method isEqualToString: is used to compare the text values contained in two NSString objects. It may be used to check whether the string is empty.

[node.name isEqualToString:@""];

However in order to check whether a string is uninitialised, use

if (node.name == nil)

or

if (!node.name)

For an explanation on the difference, check out this question.

Community
  • 1
  • 1
ZeMoon
  • 20,054
  • 5
  • 57
  • 98