Swift中“!”前缀的实际含义是什么?

问题描述:

我想知道前缀!。我创建了一个应用程序,它有tableView。而且我使用setEditing:animated属性编辑tableView,它允许多选。当用户开始选择?我们需要取消继续操作。当然,我们需要重写shouldPerformSegueWithIdentifier方法。这是我的代码Swift中“!”前缀的实际含义是什么?

override func shouldPerformSegueWithIdentifier(identifier: String, sender: AnyObject?) -> Bool { 
     return !editing 
    } 

首先,我试过使用return editing。即使运行时错误,Xcode也不会给我任何错误。一切似乎都很好。但赛季仍然有效。然后我尝试使用前缀return !editing。完美的作品!这个前缀!的实际含义是什么?

由于

+3

看看这个答案http://*.com/questions/24018327/what-does-an-exclamation-mark-mean-in-the-swift-language – iMuzahid

+0

非常感谢。这非常有帮助 – Beginner

!操作者是逻辑的NOT的布尔值;即!true变成false,!false变成true

+0

很好的答案!非常感谢! – Beginner