首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何使XCode 6只显示相关的代码完成

如何使XCode 6只显示相关的代码完成
EN

Stack Overflow用户
提问于 2015-05-23 07:45:17
回答 2查看 69关注 0票数 0

在XCode 6中,使用Swift;让我们假设我正在创建某个对象的实例:

代码语言:javascript
运行
复制
let sessionConfiguration = NSURLSessionConfiguration()

有没有办法告诉XCode 6代码完成只包括实际定义在NSURLSessionConfiguration类或超类上的方法/属性?

使用上面定义的对象,XCode代码完成建议我使用如下方法:

代码语言:javascript
运行
复制
sessionConfiguration.accessibilityActionDescription(action: String)
sessionConfiguration.animationDidStart(anim: CAAnimation!)

但我看不出这些方法与这个类相关。

在专注于代码安全的新Swift编程范式中,这似乎是一种奇怪的行为。

EN

回答 2

Stack Overflow用户

发布于 2015-05-23 08:11:09

代码语言:javascript
运行
复制
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

...}

这两种方法分别是在UIAccessibilityCAAnimation中对NSObject声明的扩展。

票数 0
EN

Stack Overflow用户

发布于 2015-05-23 15:37:40

基于博茂园的回答。我原来问题的答案是:

不是的。

XCode自动完成显示类层次结构中的每个方法。有些方法是通过继承添加到类中的,有些是通过扩展添加到类中的。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30410272

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档