In Xcode, you can control-click on a function definition, and choose "Find Call Hierarchy" from the context menu. This shows all the callers of that function, in the left side navigation area.
This also works for properties, but it it only shows calls to the getter. Is there a way to see calls to the setter?
Selecting the menu item caused Xcode to write Foo.setter:bar in the search field. I tried replacing getter with setter, and it didn't seem to work. (Actually, it seems to have triggered a bug in a Xcode. A process called com.apple.dt.SKAgent is now chewing huge amounts of CPU and has to be killed.)
This has changed in Xcode 11 (checked in version 11.4.1). Now using either "Find Call Hierarchy" or "Find Selected Symbol in Workplace" context menu command finds usages of all getters and setters of the property. There doesn't seem to be a way to find either only getter or setter at the moment.
Related
In other IDEs during code complete, I could type any char/word inside the method (doesn't have to be in the order it apears) and it will filter out those methods.
So far, it seems like in Xcode, I'll have to type out the name of the method from beginning to end in order, else the autocomplete popup disappears.
Is there any way to get this "omnisearch" feature in Xcode?
XCode's auto complete does not support that.
I've been frustrated lately with the fact that when stopped at a breakpoint in XCode 5's debugger, the list of variables for a class does not show all the ones in the class. For instance, SplitViewController only shows UIViewController as its only contents.
I've noticed however if in the console I type "po self.myVariable." (notice the . it ends with) then an autocomplete dialog pops up with a complete listing of all variables, including ones inherited from parent classes... exactly what I'm looking for, but hard to read since you can only see about 5 of these at a time in the tiny non-resizable pop-up window.
Is there a setting somewhere that I can enable to make all these values show up in the class list XCode shows on the left? (The ones where you expand classes by clicking the triangle.)
In the lower left corner of the debug panel there is a multi-choice selector that controls the variables displayed when stopped. The default state is "Auto", which I think tends to mean recently modified, and probably what yours would be set to. You can change it to "Local Variables" or "All Variables, Globals, Registers, and Statics".
Does Xcode have a way to show the caller function of a method? I want to know all of the calling functions of a method in a class. A solution would be to find the method in the project, but sometimes different classes have methods with the same name - That could find us a method we're not looking for..
Many other IDEs have this capability, such as Visual C++ 2003/2005/2008,Eclipse ...
Can you do this in XCode?
Xcode 4.4 intrudced this functionality:
New Features in Xcode 4.4 (Scroll down to 'Find and Search Additions')
Move your cursor on top of the function you are interested in
Open the Assistant editor(⌃ +⌘+Enter)
On the top of the assistant editor, Select 'Callers'
You will see a list of all the function that's calling your function
Not the as effective as other IDEs, but does the job.
Yes. Set a breakpoint inside your method, then when it breaks, there are two spots to see a stack. First is in Xcode's "console" area (usually the bottom middle), there is a top-bar which may not immediately appear to be navigable, but it is a select-style UI control which has the entire stack in it. Selecting a different level shows you that scope's variables, etc. and pops your editor to that exact file (where you can mouse-over variables to see their in-memory real-time values). Second is in the left-hand area (where you normally browse files). There is another tab there (besides the file browser) for exactly this purpose. There is a slider at the bottom which controls how many "steps" in the stack you see; clicking on one has a similar affect.
For simple refactoring such as method re-naming, you can use the contextual-menu when you right-click a selected method-name, and Xcode will replace all identical selectors in your project. However, this does not address what you mentioned about different classes having methods with the same signature. It does, however, give you a very nice interface for reviewing the changes in-context and easily accepting or rejecting them one at a time.
It might be noted, however, that changing method signatures often may be a sign of poor design, and particularly if you have to do it with methods which have the same signature on different classes (which are not "siblings" and therefore should both get the rename)
I have written an installerplugin to show a custom pane in the pkg installer. I want to display the pane only during first install and hide it when upgrading. I know how to find out if the package has already been installed or not but I am not able to figure out the logic of showing/hiding the installerpane based on a runtime decision.
One method I could think of is that the installerplugin contains an Installersection outlet called parentSection. And installersection class has a function shouldload whose return value decides whether the section should be loaded or not. And this article mentions that the installersection methods can be overloaded. But I am unable to think of a way to overload the functions as parentSection is just an object inside the installerpane class.
Even though it's been several months since sanmukh asked this question, I figured I would post the answer since I figured out how to do this.
The solution is indeed to subclass InstallerSection and override the shouldLoad method. To use it, you have to edit your plug-in's Info.plist file and change the entry for "NSPrincipalClass" (or "Principal Class" as it appears in Xcode 4) to be your new InstallerSection derived class. Afterwards when your package loads, the new shouldLoad method will be called, allowing you to programmatically decide whether the installer pane should be visible.
I'm implementing a Visual Studio Language Service for a custom scripting language used internally at my company, and I've run into an issue with the navigation bar implemented as a subclass of TypeAndMemberDropdownBars. The subclass is created by my LanguageService subclass' LanguageService.CreateDropDownHelper method.
In the OnSynchronizeDropdowns method I'm iterating through the types defined in the file and adding DropDownMembers to the passed-in array to fill out the navigation bar. The issue I'm seeing is that the first item in the array is being duplicated and placed at the end of the listing by code that I don't have access to. This extra item does not behave correctly when selected (nothing happens), but doesn't seem to cause any other issues; the rest of the items in the list work fine. Additionally, this only seems to happen for the type dropdown box - the members dropdown box does not display this behavior.
I'm hoping someone else has seen and resolved this issue and could provide some assistance. Thanks!
Turns out this was caused by me calling LanguageService.SynchronizeDropdowns from my LanguageService.ParseSource method, which was being called on a background thread. I've fixed the problem by setting a flag when ParseSource does a Check parse, and then implementing a check for that flag in my LanguageService.OnIdle function that will call SynchronizeDropdowns. It's now working as expected!
A better solution is to implement the LanguageService.OnParseComplete callback, and call SynchronizeDropdowns from there. OnParseComplete is always called from the main thread, so this prevents any synchronization issues from coming up, and also keeps you from having to keep track of whether or not you need to call SynchronizeDropdowns().