English 中文(简体)
红十字与红新月联会条款没有确认恢复国家稳定功能?
原标题:IF clause is not validating NSString function return?

我的职能如下,可证实另一职能的恢复(恢复安保部职责的搜索功能)。 在我执政时,如果说不使用这一条款,那么,由于国家安全记录仪(@“功能回归:%@”,诺瓦卢尔)出现在康索尔。

Can someone tell me if there s any mistake in the code? (For sure there is a mistake!)

- (void) buttonPushRandomViewController1 {

    UIViewController *randomViewController = [self randomViewController3];

    NSString *novaurl = [self searchPlaces];
    NSLog(@"Function Return: %@",novaurl);

    if (novaurl == @"OK") {
        randomViewController.title = @"Resultado";
        [self.master pushViewController:randomViewController animated:YES];

        NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:novaurl]];
        [webView loadRequest:request];
    }else if (novaurl == @"ZERO_RESULTS") {
        UIAlertView *zeroResults = [[UIAlertView alloc] initWithTitle: @"Ops!" message: @"Sorry, nothing found!" 
                                                             delegate: self cancelButtonTitle: @"OK" otherButtonTitles: nil];
        [zeroResults show];
        [zeroResults release];
    }
}

提前感谢!

最佳回答

您不应将<代码>NSStrings与=的操作者进行比较。 <代码>=的操作者在目标-C物体类型上履行参比平等>:只有在两种操作方式都提到同一物体时,才返回。 即使有两条插图是彼此的拷贝,=如果提及不同情况,也会退回。

You want to use value equality instead. You can compare strings using the -isEqualToString: method:

if ([novaurl isEqualToString:@"OK"]) {
    ...
}
问题回答

您应使用<条码>isEqualToString:方法,用于检查舱位平等情况。 = 操作者进行点比较,有时会退回NO,尽管星体的内容相同。





相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...