如何将以下代码更新为swift 2我是新的
if($cond)
{
$layout = view('master');
}
else
{
$layout = view('master2');
}
$page = view('page');
$layout->content = $page;
return $layout;
答案 0 :(得分:1)
您必须在 try catch 中使用此代码,如下所示。
if let rtf = NSBundle.mainBundle().URLForResource("rtfdoc", withExtension: "rtf") {
do {
let attributedString = try NSAttributedString(fileURL: rtf, options: [NSDocumentTypeDocumentAttribute:NSRTFTextDocumentType], documentAttributes: nil)
textView.attributedText = attributedString
textView.editable = false
print(attributedString)
} catch let error as NSError {
print(error.localizedDescription)
}
}