您的位置:首页 > 移动开发 > Swift

swift学习记录(selector)

2015-04-05 16:03 232 查看
转载自: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中被引入,因为他们是不安全(固有的)的。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: