I have a little question. Seems easy but I don’t get it working.
All I want is check if a string is empty or not. Here’s what I have so far:
if(mystring.text != @""){
myPath = [myPath stringByAppendingString:mystring.text];
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
To compare an
NSStringto another one, you would useisEqualToString. You’re checking for inequality, so it would be:But really, since you’re just checking if the string is empty, you’ll want something like
Note that if
textisnil, the code in theif-statement will not execute. This is because[nil length]will return0. For more information about that, see “Sending Messages to nil” in Apple’s documentation.I suspect
mystring.textis anNSStringin your case, so it would be