在XCode 6中,使用Swift;假设我正在创建一个对象的实例:
let sessionConfiguration = NSURLSessionConfiguration()
有没有办法告诉XCode 6代码完成只包含在NSURLSessionConfiguration类或它的超类上实际定义的方法/属性?
使用上面定义的对象XCode代码完成表明我使用的方法如下:
sessionConfiguration.accessibilityActionDescription(action: String)
sessionConfiguration.animationDidStart(anim: CAAnimation!)
但是我看不出那些方法与这个类有关。
这似乎是一种痴迷于代码安全的新Swift编程范式中的奇怪行为。
答案 0 :(得分:0)
extension NSObject {
/* Called when the animation begins its active duration. */
func animationDidStart(anim: CAAnimation!)
/* Called when the animation either completes its active duration or
* is removed from the object it is attached to (i.e. the layer). 'flag'
* is true if the animation reached the end of its active duration
* without being removed. */
func animationDidStop(anim: CAAnimation!, finished flag: Bool)
}
extension NSObject {
/*
Implement accessibilityActivate on an element in order to handle the default action.
For example, if a native control requires a swipe gesture, you may implement this method so that a
VoiceOver user will perform a double-tap to activate the item.
If your implementation successfully handles activate, return YES, otherwise return NO.
default == NO
*/
@availability(iOS, introduced=7.0)
func accessibilityActivate() -> Bool
...}
这两种方法是在 CAAnimation 和 UIAccessibility
中扩展NSObject声明答案 1 :(得分:0)
基于bumaociyuan的回答。我原来问题的答案是:
没有
XCode自动完成显示类层次结构中的每个方法。一些方法通过继承添加到类中,一些通过扩展添加。