A shortcut for ...

Discussion in 'iOS Programming' started by nashyo, Aug 15, 2012.

  1. macrumors 6502

    nashyo

    Joined:
    Oct 1, 2010
    Location:
    Bristol
    #1
    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
     
  2. macrumors member

    Joined:
    Mar 27, 2012
    #2
    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 ="
     
  3. macrumors 6502a

    Duncan C

    Joined:
    Jan 21, 2008
    Location:
    Northern Virginia
    #3
    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.
     
  4. macrumors 68030

    MattInOz

    Joined:
    Jan 19, 2006
    Location:
    Sydney
    #4
    Also in xCode 4.4 the counterpart editor has the option to show "Callers" of the class you are editing.
     
  5. macrumors 6502a

    Duncan C

    Joined:
    Jan 21, 2008
    Location:
    Northern Virginia
    #5
    Cool. I did not know about that. Is that new in 4.4?
     
  6. macrumors 68030

    MattInOz

    Joined:
    Jan 19, 2006
    Location:
    Sydney
    #6
    Yeah, they added a few new counterparts in 4.4.
     

Share This Page