“跳转到定义"对于没有外部参数名称的方法 [英] "Jump to definition" for methods without external parameter names
问题描述
对于带有外部参数名称的方法调用我可以在Xcode中cmd-单击任何参数名称以跳转到方法定义.为了例如,在
For method calls with external parameter names I can cmd-click in Xcode on any parameter name to jump to the method definition. For example, in
let a = Array(count: 3, repeatedValue: 0)
a cmd-点击count"或repeatedValue"直接跳转到Array
初始化方法
a cmd-click on "count" or "repeatedValue" jumps directly to the Array
initializer method
init(count: Int, repeatedValue: Element)
但是,我还没有找到对方法调用执行相同操作的方法没有外部参数名称,如
However, I haven't found a way to do the same for methods calls without external parameter names, as in
let c = Array("abc".characters)
当然我可以查到 characters
方法返回一个 String.CharacterView
,它又符合 SequenceType
,所以这将调用Array
初始化器
Of course I can lookup that the characters
method returns a String.CharacterView
which in turn conforms to SequenceType
, so this will call the Array
initializer
init<S : SequenceType where S.Generator.Element == _Buffer.Element>(_ s: S)
但我想知道是否有人找到了直接跳转到定义"的方法对于这种情况.
but I wonder if somebody has found a direct "jump to definition" method for this situation.
如果一个类型有许多重载的 init 方法(没有外部参数名称),这将非常有用,以确定实际调用的是哪个.
This would be very useful if a type has many overloaded init methods (without external parameter names), to determine which one is actually called.
以上例子来自Swift 2/Xcode 7 beta,但问题不在于绑定到一个特殊的 Swift/Xcode 版本.
The above examples are from Swift 2/Xcode 7 beta, but the problem is not tied to a special Swift/Xcode version.
(也在 Apple 开发者论坛上发布:https://forums.developer.apple.com/thread/12687.)
(Also posted at the Apple Developer Forums: https://forums.developer.apple.com/thread/12687.)
推荐答案
你必须做一些工作:
let c = Array.init("abc".characters)
// ^^^^^
使用 初始化表达式,然后cmd + 点击它.
Use initializer expression, then cmd + click on it.
这篇关于“跳转到定义"对于没有外部参数名称的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!