Ios 需要帮助将Apple文档解释为Xcode吗

Ios 需要帮助将Apple文档解释为Xcode吗,ios,xcode,swift,Ios,Xcode,Swift,我正在为UIAlertController解释苹果的代码片段 ()将在Xcode中使用 // Configuring and presenting an alert UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"My Alert" message:@"This is an alert." preferredStyle:UIAlertControllerStyleAlert]; U

我正在为UIAlertController解释苹果的代码片段 ()将在Xcode中使用

// Configuring and presenting an alert
UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"My Alert"
    message:@"This is an alert."
    preferredStyle:UIAlertControllerStyleAlert];

UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault
   handler:^(UIAlertAction * action) {}];

[alert addAction:defaultAction];
[self presentViewController:alert animated:YES completion:nil];
在Xcode中,它写为:

在Xcode中,其写入方式为:

let alertController = UIAlertController(title: "My Alert", message: "This is an alert.", preferredStyle: UIAlertControllerStyle.Alert)
alertController.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: nil))
self.presentViewController(alertController, animated: true, completion: nil)
取自AppCoda

看起来一点都不像

如果我没有从教程和源代码中寻找使用UIAlert的示例,我想我不可能仅凭苹果的文档就能在Xcode上使用UIAlert

那么,在不需要其他来源的教程和示例代码的情况下,我如何从苹果的文档中获取工作代码呢


谢谢大家

第一段代码是用Objective-C编写的,第二段代码是Swift。哦,我明白了,所以苹果没有更新Swift的文档?至少你发布的链接可以在swfit和Objective-C之间进行更改,但只修改标题,源代码保持不变。好的,我现在明白了,谢谢!)