このボタンアクションを実装しようとしていますが、ifステートメントがtrueと評価されていません。その「学校」辞書の値に、常にWebサイトが保存されているとは限らないという状況があります。そのため、確認したいのですが、何を確認しますか。値がないときに「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];
}
}