swift学习记录(selector)

来源:互联网 发布:淘宝韩束旗舰店 编辑:程序博客网 时间:2024/06/11 07:47

转载自:http://stackoverflow.com/questions/24007650/selector-in-swift

https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/BuildingCocoaApps/InteractingWithObjective-CAPIs.html#//apple_ref/doc/uid/TP40014216-CH4-XID_26


原文:An Objective-C selector is a type that refers to the name of an Objective-C method. In Swift, Objective-C selectors are represented by the Selector structure. You can construct a selector with a string literal, such as let mySelector: Selector = "tappedButton:". Because string literals can be automatically converted to selectors, you can pass a string literal to any method that accepts a selector.


翻译:在Objective-C 中 selector是指向方法名的类型,在swift中Selector由结构构造,你可以直接用字符串构造一个Selector,例如:let mySelector = "tappedButton",因为字符串可以自动转化成selectors,你可以直接输入方法名的字符串,来适配一个selector。


原文:NOTE

The performSelector: method and related selector-invoking methods are not imported in Swift because they are inherently unsafe.


翻译:注意:

performSelector方法和设计selector的方法并没有在Swift中被引入,因为他们是不安全(固有的)的。

0 0
原创粉丝点击