@synthesize problems

Discussion in 'Mac Programming' started by blue-lion, Dec 3, 2010.

  1. macrumors member

    Jan 26, 2010
    Hello, i am having problems with the synthesize/property statement.

    In the header i write

    @property int fillColor;

    and in the implementation file i write

    @synthesize fillColor;

    I've read that setter methods are created this way so,when i use the function below, it should work...right?

    [object1 setfillColor 2] ;

    I get a message saying "[GraphicObject fillColor:]: unrecognized selector sent to instance 0x10010c6d0"

    GraphicObject is my class.

    obviously i've omitted all the commands from the headers/footers for clarity.

    can anybody help?
  2. macrumors 604

    Aug 9, 2009
    Reread the reference docs on properties, paying particular attention to the capitalization algorithm for mapping property names onto method names.
  3. macrumors 68000


    Feb 11, 2010
    First off, the basic syntax is off:

    [object1 setfillColor:2] ; --- notice the colon

    And I believe it would actually be:

    [object1 setFillColor:2] ; --- capitalization.

    That's the pretty standard notation with auto-created/called getters and setters
  4. macrumors 6502a

    Dec 2, 2008

    I'm not at my Mac right now, but off the top of my head you may want to capitalize the "F" in setFillColor.
  5. thread starter macrumors member

    Jan 26, 2010
  6. macrumors 68030


    Dec 8, 2003
    What they said. But your specific error is not a setter, but a getter. There should be no : after that selector.

Share This Page