xcode iOS compare strings

前端 未结 5 2066
北恋
北恋 2020-12-14 15:37

How do i compare a website result with a predicted result.

@\"document.getElementsByTagName(\'body\')[0].outerHTML\"

is predicted to contai

5条回答
  •  忘掉有多难
    2020-12-14 15:57

    if (webresult == cmp)
    

    Here, == checks whether webresult, cmp are pointing to the same reference or not. You should instead compare value of the object by using NSString::isEqualToString.

     if ( [ cmp isEqualToString:webresult ]) {
       // ..
     }else {
       // ..
     }
    

    Note that isEqualToString is a good option because it returns boolean value.

提交回复
热议问题