我正在尝试实现此按钮操作,但 if 语句未评估为真。我有一种情况,即“学校”字典中的值并不总是存储一个网站。出于这个原因,我想检查,但我要检查什么。如果没有值时没有存储“nil”,那是什么?
-(IBAction) btnVisitWebsite_clicked :(id)sender {
if([School objectForKey:WEBSITE_KEY] == nil){
UIAlertView *NoWebsite = [[UIAlertView alloc]initWithTitle: @"No Website"
message:@"The selected school has not listed a website"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
NoWebsite.tag = 15;
[NoWebsite show];
[NoWebsite release];
NoWebsite = nil;
}
else{
NSMutableString *WebsiteVisit = [[NSMutableString alloc] initWithString: @"http://"];
[WebsiteVisit appendString:[School objectForKey:WEBSITE_KEY]];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString: WebsiteVisit]];
[WebsiteVisit release];
}
}