// // ViewController.swift // test_nil_swift // // Created by jeffasd on 17/3/13. // Copyright © 2017年 jeffasd. All rights reserved. // import UIKit class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view,typically from a nib. } override func touchesBegan(_ touches: Set<UITouch>,with event: UIEvent?) { showName(nil); self.view.backgroundColor = UIColor.blue; } //MARK: swift3.0判断变量是否存在 func showName(_ name: String?){ if name != nil { print("name") }else{ print("anme is nil") } } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。