I'd like to add a couple caveats to my previous post.
First, if you Cmd-Cntrl-click on a symbol, the editor will take you to the declaration of that symbol, as I said above. However, once you've Cmd-Cntrl-clicked on a symbol and it's declaration is displayed in the editor, you can scroll around in the editor. Wherever you scroll to will be the location displayed when going back to that symbol's place in the reference stack, whether the symbol you clicked on is shown in the window or not.
Second, it seems that Cmd-Cntrl-clicking will attempt to select any static tabs that have already been established for the newly opened file. However, if the file doesn't have any static tabs referencing it, a new temporary tab will be created and any subsequent Cmd-Cntrl-clicks on symbols in other files for which there are no static tabs will replace the file in the newly created temporary tab.
Again, I haven't exhaustively tested this, so I'm open to any corrections that others find in this behavior.
Post
Replies
Boosts
Views
Activity
Here's my attempt to answer dogcoder's issue (3rd paragraph):
Like grb2007, I've found out the following through experimentation rather than through Apple's Xcode documentation, though I tried hard to go that route.
If you open a project and close all the document (not window) tabs, to start fresh, then open a file in the project navigator, a temporary document tab is opened. Ignoring the tabs for a moment, if you click a couple more files in the project navigator, their contents will be displayed in the editor window. After doing that a few times, you'll find that swiping left or right works as you expected. It will go back and forth between the files you opened in the order that you opened them.
However, the more valuable use of swiping left and right, which matches the behavior of clicking the back and forward buttons in the document tab bar, is to do a manual "stack trace" through your functions and methods.
If you're examining a function's code and it calls another function, you can Cmd-Cntrl-click that second function's name to immediately open its file with it's declaration selected. As you go through its code, you Cmd-Cntrl-click a function it calls to move deeper into the logic. Again, that function's file will open with it selected. Let's say you repeat that sequence three or four more times. Now you're pretty deep in the calling sequence but how do you get back? The incredibly valuable answer is either the back button or swiping. Each back button click (or swipe right) will take you back to the calling function, so you can very conveniently move right back up the calling stack.
This approach includes clicks on any symbol, as far as I can tell, so you can use it to examine type and named value (let or var) declarations as well as function declarations and find your way back up to the top of the reference "stack" when you're done. Of course, if you go half way back up, then click the forward button (or swipe left), you'll retrace your steps back down the stack.
As you'd expect, if you go half way back up, then Cmd-Cntrl-click another symbol, the original stack below you will be lost and replaced by this new reference. Of course, this works whether the symbol you clicked was in another file or the same file you were already in. In either case, your editor window will display the referenced symbol's definition which will be added to the stack. This means that sometimes when you go back up the "stack trace", you will move within a file rather than opening a new file in the editor.
I just discovered this yesterday and haven't yet experimented with the relationship between these clicks and the document tabs but I thought this might be helpful for some.
I just found from the documentation that I can declare, decompose and initialize a tuple constant or variable on the same line:
var z: (x: Int, y: Int) = (14, 17)
print("x = \(z.x), y = \(z.y)") // prints: x = 14, y=17
This was what I was trying to do from the outset when I got the earlier error. I see now that the error I got was about a conflict in my declaration with x being declared in an earlier declaration.
Thank you, OOPer,
I tried your last suggestion of type annotations for tuple decomposition and it worked perfectly in my test playground on Xcode 12.0.1/Swift 5.3.
I'm a Swift newbie trying to learn the language. I read the description of tuples in The Basics chapter of the Swift Language Guide but felt that the explanation omitted any reference to type annotations. I was attempting to experimentally determine how one adds type annotations to a tuple declaration and failed. Your example answered that question and seems to be a more elegant solution on the part of the language developers than the experimental notation that I attempted.
Though I can offer no use cases at this time, ask me that again in a year.
Again, thanks,
Jerry
Ken,
Thanks for your response and for your (misplaced) faith in my Swift abilities. I'd figured out the first 6 of your 8 listed letter icons. I hadn't pinned down T - Type (Alias) and V - (Global) Variable yet.
I'd also figured out the box with four dots (Framework/API topic top) as a Framework but had never looked up documentation through that path so hadn't realized that it pointed to the top document. I was clueless on the Chapter/section top and Article icons, though once I saw your answer it seemed like they should have been obvious.
So, though it may seem like you've only marginally helped me, the fact that you've provided an exhaustive list (it is exhaustive, isn't it?) with clear explanations makes me feel like the icons have suddenly become more useful and are worth memorizing.
Thanks, again.
Jerry
Hi, KMT,
I'm sorry for the delay. As a newbie, I had to figure out how to get back to this thread before I discovered your answer.
The developer documentation I was viewing was not online. It was that presented directly by Xcode. That is, if you activate Xcode and enter Cmd-Shift-Zero, a documentation page is displayed by Xcode. The page displayed seems to be the last page that you referenced in the documentation, but that's an aside that I'm not asking about. If you haven't referenced the Xcode documentation, I'm not sure what page it would display for you.
This displayed page has a column of sections along the left side. Each of the entries in that column is prefixed by an icon of the type I was asking about. There's also a search text box at the top of the page. If you enter a search argument, as you type, a dynamic list of predicted answers is displayed based on the characters you've already typed. Each entry in that list is also prefixed by the icons that I was asking about.
Ultimately, you go to the page you were searching for by selecting a line on that list. It would be helpful to know what all the icons meant when I have to choose a line prefixed by one of them.