Swift里的AlertController即OC里的AlerView

    let alertController = UIAlertController(title: "New Resolution",                
message: "", preferredStyle: UIAlertControllerStyle.Alert)
    //confirmAction
    let confirmAction = UIAlertAction(title: "Confirm", style:   
UIAlertActionStyle.Default, handler: ({
        (_) in
        if let field = alertController.textFields![0] as UITextField!{
            self.saveItem(field.text!)
            self.tableView.reloadData()    
        }
    }))
    
    let cancelAction = UIAlertAction(title: "Cancel", style:      
UIAlertActionStyle.Cancel, handler: nil)

    alertController.addTextFieldWithConfigurationHandler ({
        (textField) in
        textField.placeholder = "Type smothing..."
    })
    
    alertController.addAction(confirmAction)
    alertController.addAction(cancelAction)

    self.presentViewController(alertController, animated: true, 
completion: nil)

推荐阅读更多精彩内容