Auto Generate Getter/Setter Methods?

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

  1. Vortec4800
    Expand Collapse
    macrumors member

    Apr 15, 2008
    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. Spike099
    Expand Collapse
    macrumors regular

    Feb 18, 2007
    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. Vortec4800
    Expand Collapse
    thread starter macrumors member

    Apr 15, 2008

Share This Page