If statement checking for NSString equality using ==

馋奶兔 提交于 2019-11-28 14:29:07
W Dyson
if ([returnStringResults isEqualToString:yesText]) {
    testLabel.text = @"Success";
    // DO ACTION HERE
}

Edit: As bbum pointed out, NSString *returnStringResults = returnString; does nothing.

So really, remove that line and use

if ([returnString isEqualToString:yesText]) {
    testLabel.text = @"Success";
    // DO ACTION HERE
}

You're comparing pointer addresses. The way this code works yesText and returnStringResults are pointers to different NSString instances, thus the pointers are not equal. You've to use NSString isEqualToString method to compare.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!