内容简介:翻译自:https://stackoverflow.com/questions/36147831/syntax-selector-swift-2-2
我正在尝试修复我的NSNotificationCenter并且它无法正常工作
消息:
'Use of string literal for Objective-C selectors is deprecated; use '#selector' instead'.
这条线:
NSNotificationCenter.defaultCenter().addObserver(self, Selector :#selector(GameViewController.goBack)(GameViewController.goBack), object: nil) self.dismissViewControllerAnimated(true, completion: { }); }
@ Eendje的回答是不正确的第一条评论.
我认为这是更好的答案.
NSNotificationCenter.defaultCenter().addObserver(self, #selector(self.goBack), name: "your notification name", object: nil)
如果某些操作有目标,则应该显示为#selector(target.method)或#selector(target.method(_ :))
这是另一个例子
UIGestureRecognizer(target: target action:#selector(target.handleGesture(_:))
翻译自:https://stackoverflow.com/questions/36147831/syntax-selector-swift-2-2
以上所述就是小编给大家介绍的《语法“Selector”Swift 2.2》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
猜你喜欢:- Swift语法快速入门(一)之 Swift基础语法
- 在ES6中使用扩展语法有什么好处?它与rest语法有什么不同?
- Python 基础语法
- go语法
- JPQL 语言语法
- reStructuredText简明语法
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Text Processing in Python
David Mertz / Addison-Wesley Professional / 2003-6-12 / USD 54.99
Text Processing in Python describes techniques for manipulation of text using the Python programming language. At the broadest level, text processing is simply taking textual information and doing som......一起来看看 《Text Processing in Python》 这本书的介绍吧!