Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
820 views
in Technique[技术] by (71.8m points)

xcode - "Jump to definition" for methods without external parameter names

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-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)

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.

This would be very useful if a type has many overloaded init methods (without external parameter names), to determine which one is actually called.

The above examples are from Swift 2/Xcode 7 beta, but the problem is not tied to a special Swift/Xcode version.

(Also posted at the Apple Developer Forums: https://forums.developer.apple.com/thread/12687.)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You have to do some work:

let c = Array.init("abc".characters)
//           ^^^^^

Use initializer expression, then cmd + click on it.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...