如何在if语句中使用字符串?

ato*_*nda 1 string iphone if-statement objective-c nsstring

我是objective-c的新手,我想知道如何获取NSString的stringValue,如果它等于照片,那么 //something

这是我正在使用的代码,NSLog打印"照片".

我正在为iPhone开发.

NSString *getPageType = [self.webView stringByEvaluatingJavaScriptFromString:
                                 @"document.getElementById('pageType').name"];

    NSLog(@"%@", getPageType);



    if (getPageType == @"photo")
    {
        [UIButton animateWithDuration:3 animations:^{
            downloadOverlay.alpha = 1;
            downloadOverlay.alpha = 0;
        }];

    }
Run Code Online (Sandbox Code Playgroud)

小智 6

if ([getPageType isEqualToString:@"photo"])
Run Code Online (Sandbox Code Playgroud)

应该做的伎俩.