Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

nashyo

macrumors 6502
Original poster
Oct 1, 2010
299
0
Bristol
Is there a shortcut for ...

Finding out where a method is called

and

Finding out where a property is set

At the moment, I can't find any kind of function that will highlight this useful information for any given method or property I have in my code. Can anyone help?

Thanks
 

Ides

macrumors member
Mar 27, 2012
95
0
I don't think there's really an official function in xcode for finding these things. But you could use Edit->Find in Workspace. That will highlight bits of code you're searching for.

Say you want to find out whenever someMethod is being called. You could do a search for "someMethod]", and that should help you locate where it's being called.

To find where a property is being called search for ".propertyName", and to find out where a property is being set search for ".propertyName ="
 

Duncan C

macrumors 6502a
Jan 21, 2008
853
0
Northern Virginia
Is there a shortcut for ...

Finding out where a method is called

and

Finding out where a property is set

At the moment, I can't find any kind of function that will highlight this useful information for any given method or property I have in my code. Can anyone help?

Thanks

To find where a method is called, use the editor to search all files in your project for the method name (edit menu>find>find in workspace, or command shift F).

To figure out where an instance variable is being changed, there is a facility in the Xcode debugger called watchpoints. They've been broken for a while, but they seem to be fixed again in Xcode 4.4.

To set a watchpoint, stop your program at a breakpoint in the class who's instance variable you want to watch. Then go to the variables view in the debug area, open the disclosure triangle next to "self", and find the variable you want to watch. Right click on it and select the item 'Watch "<variablename>"' in the popup that appears. Watchpoints are listed along with code breakpoints in the breakpoint navigator, and you can enable and disable them as desired.

Once you've set a breakpoint, the next time your code changes that variable, the debugger will stop it and show you the line.
 

MattInOz

macrumors 68030
Jan 19, 2006
2,760
0
Sydney
Also in xCode 4.4 the counterpart editor has the option to show "Callers" of the class you are editing.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.