Auto Generate Getter/Setter Methods?

Discussion in 'Mac Programming' started by Vortec4800, Apr 15, 2008.

  1. macrumors member

    Joined:
    Apr 15, 2008
    #1
    Is there a way to get Xcode to generate getter and setter methods for a bunch of instance variables? I've got around 20 of em and it's sure tedious to do it for each class...
     
  2. macrumors regular

    Joined:
    Feb 18, 2007
    Location:
    Canada
    #2
    There are a couple of methods to achieve this.

    First and Recommended.
    Synthesizing, it would be best to read about this in the documentation.

    Second, if you just want a quick and dirty way to do it(the old way), however this could be used with dynamic synthesizing aswell.
    In the menu bar in Xcode, you'll see a script menu. Highlight the variables that you would like the getter setter methods for, select script menu -> code -> Place accessor Decls on Clipboard / Place accessor Defs on Clipboard

    Then paste into your interface and implementation files appropriately.
     
  3. thread starter macrumors member

    Joined:
    Apr 15, 2008
    #3
    Fantastic. Thank you!!
     

Share This Page