xcode - 如何在 Swift 中表示 NULL 选择器

标签 xcode swift

当我尝试使用函数 .removeTarget(nil, action: NULL, forControlEvents: UIControlEvents.AllEvents) 删除所有关联的操作时

我意识到你不能使用 NULL。那这里用什么?

非常感谢!

最佳答案

NULL 选择器可以用 nil 构造:

let sel:Selector = nil

Selector()

所以你可以:

.removeTarget(nil, action: nil, forControlEvents: .AllEvents)
// OR
.removeTarget(nil, action: Selector(), forControlEvents: .AllEvents)

关于xcode - 如何在 Swift 中表示 NULL 选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27648708/

相关文章:

ios - Swift 使用没有泛型的动态类型引用创建类型数组

ios - 在 XCode 中更改为映射模型未在模拟器包中更新

iOS 10 Swift 和定义 UI 的最佳实践

swift - Xcode 8 Swift 3 改变音调的声音

ios - 如何开始在 mac os 的 cocoa 应用程序中处理标签?

python - 将 Django json 导入 iPhone App

ios - 基于手机调整UIScrollView中UIView和UIButton之间的约束高度

ios - 如何从 NSURLSessionDataTask 获取状态码?

json - 使用 alamofire + swift 获取动态加载的 html

ios - 分享 pdf 文档 .Swift