Xcode quickly jump to Action associated with a Control - xcode

Is there a quick way to jump to an action associated with a control.
Say there is a button on a XIB file that has an associated action. The way to find the code associated with this is rather tedious. Is there a short cut that can quickly jump to the code.
I am spoiled by Visual Studio - double click on a button and it takes you to it's handler

The fastest way I know to at least get quickly to the source file in which the action resides is the following:
select the button in the UI editor
hit ctrl+1 (this will open the “Related Files” drop down)
navigate to the “Sent Actions” sub-menu, e.g. via s, enter
select the relevant class (I think in this case there can only be one, so just hit enter again)
Once you are in the class, the action should be easy to find. If that's not the case, because your source file is so big, type ctrl+6 to open the “Document Items” drop down and start typing the name of the action. Once you see the action, select it via keyboard or mouse.
If you often don't know the name of the action, you will have to look it up before navigating to the class, e.g. by right clicking on the button.

I would advise to use ^+⎇+⌘+Enter to get to referenced code file. There you can search for #IBActions or #Outlets. If a UIButton has a segue attached, this method won't help to find it.
To review a list of actions, segues and outlets you can select an object on the storyboard and press ⎇+⌘+7 to open Connections Inspector on the right pane.

Related

manual option is not showing in Xcode 11 assistant editor and how to add IBOutlet?

I recently updated to Xcode 11 and some of its user interface changed. in older version of Xcode there was options of accessing files in assistant editor using automatic or manual. but in this version of Xcode I can't see any manual option in assistant editor. so I am not able to add IBOutlet and IBAction methods to particular storyboard.
so can anyone tell me how to add these actions and outlets, that would be great help. thanks
By pressing the above button, Xcode will split the view and allow you to select a custom file using the file tree at the top.
You are correct.
The Manual option is no longer visible. You can still achieve the same result by doing a quick open using Cmd+Shift+O then type the name of any file you want to open. Press the Alt key and the file will open in the Assistant Editor Window.
As others have noted the new add editor button allows you to add new editors and open files into them. You could file a bug report but you may want to consider that you're likely to get a "works as designed" type of reply.
You can always change or add new keyboard shortcuts to get the behavior you want by viewing the preferences key bindings area and search for the command you want to shortcut.
Note
You can still ctrl+drag from storyboard to the class by the Adjust
Editor button in the upper right of the storyboard. Then just select
Assistant Editor on the list. After which you can make IBOutlets/IBActions.
open your storyboard, hold option key and select the file you want
In the documentation outline of storyboard, try to choose the "correct" item, which you want to set up outlet connections. Say you want to set up an outlet connection for cell of table/collection view.
View Controller > Collection View > Cell > Content View > Image View.
Try to select Cell, "Content View" or "Image View", then check the jump bar of assistant editor, you're probably able to switch to the .swift file you want.
Reference

File chooser in a default Cocoa application

I have created a default [Swift] Cocoa application. I attempted to Ctrl drag from the default Open button in the menu to my View Controller in the assistant editor, but nothing happens.
Is my approach wrong? I assume there is some kind of default file chooser dialog, but I do not know how to make it appear or enable the Open menu item. From the documentation I feel I could make one appear programmatically, but I want to enable the menu button.
My first attempt at an OS X program hit a wall very fast :-/
First, control-Click on Open, and see if it is already attached to a function. If so, click the x to detach it, then try again.
Second, be very sure that the Assistant Editor is presenting the correct file to do the control-Drag. I have found that I need to manually choose the correct file much of the time.

Data Driven Coded UI Testing in Visual Studio

I am curious about an issue in Coded UI Testing. For example I created a button named Button1. I did assertions and everything is fine. Then I changed this button's name to Button2. Now, do I have to write my assertions again or is Coded UI Test can suit in every different name change. Notice that I am not doing any input or parameter changes, I am just changing user interface. Thanks for your replies.
You should be able to change the test code easily to cope with a name change like that. Open the UI Map file in the UI Map editor; ie double-click on the uimap.uitest file in solution explorer. In the left hand pane expand the method and select the action that clicks the button. That should open the relevant control in the right hand pane. Alternatively just find the control for the button in the right pane. View the properties of the button and click on the ellipsis of the "(collection)" value of SearchProperties or the FilterProperties. One of the items shown should be the old name of the button, just rename it there.

VS 2010 - is there a way to implement a pop-context button, similar to what was available in vs 6

The context is this.
I have right clicked on a function name and gone to definition.
I have examined the information there and which to return to my previous source file/position.
In vs 6, the browse toolbar contained a pop context button that would do this job.
I am looking for a way to replicate that functionality.
Thanks
Evil.
The keyboard shortcut that I use is Ctrl-.
In the menu, you can find it at View -> Navigate Backward.
I know this is old, but is still very relevant and has a better solution.
The problem with Navigate Backward (previous answer) is it takes you back to any previous navigation whether by Go to definition, mouse, PgUp, PgDn, etc.
Popping the browse context is different, and navigates you back to where you originally requested the Go to definition or any of the other browse operations, regardless of any other navigation you did since.
The Pop Context keyboard shortcut is Ctrl+(* on the numeric keypad).
I like to make a button for it -
steps are as follow
go to customise for the toolbar
add/remove buttons
Add command
choose view -> Pop browse context.

Does Xcode have code navigation feature?

Does Xcode have a code navigation feature? Like unix's cscope type of tool which I can enter the name of a class and it will open the file for me? Or find out the caller of a particular method of a class? Or show the type hierarchy of a class?
command-shift-D (Xcode 4: command-shift-O) opens a Quick Open window where you can type a partial class name and hit enter to open the file. As far as more complex versions such as what Eclipse offers (method names, symbol names, etc), I don't believe anything like that is built into XCode.
In addition to the Quick Open window, there is the class browser. The class browser allows you to view the class hierarchy. The Class Browser can be found under the Project menu.
The "Jump To Definition" item is accessible through CMD + double click, which takes you directly to the relevant code
Also, you can "Jump To Documentation" by (Option or ALT) + double clicking on a class/method/property
Update:
Option + double click no longer takes you directly to documentation in Snow Leopard. Now it opens up a little documentation "bubble", with the option to jump to the documentation browser if needed.
If you Ctrl click a class name, method name or function name you will get a long meny where you can find the Jump to Definition item.
From XCode 4.4 upwards, you can find callers and callees by opening the "show related items" pop-up for a selected (highlighted) method:
Mark method in code (using your cursor or double click name)
Press Ctrl+1
Select "Callers" from the pop-up menu
You can also go View->Standard Editor->show related items or press the tiny button just left of the arrow buttons in the line just above the editor window (where it shows your currently selected file and method).
Also: select an identifier, right-click on it, and choose Find in Project > As Symbol (or Find in Project and choose Symbol as the search type) shows all symbolic uses, that is, declarations, definitions, and call sites.
There should opens up something like an element preview window or bubble when the user point to a method or item. The "Jump to Definition" change the users focus and take 2 steps to go to the target.
The relation window and context window in Source Insight is a good example,but I can't find them in Xcode and other dev tools for the mac.
By the way,the context window should have multiple layers to trace a deep referenced method like the split window in Xcode, not only one layer in the source insight.

Resources