@synthesize problems

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

  1. macrumors member

    Joined:
    Jan 26, 2010
    #1
    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 603

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

    ulbador

    Joined:
    Feb 11, 2010
    #3
    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

    Joined:
    Dec 2, 2008
    #4
    Capitalize?

    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

    Joined:
    Jan 26, 2010
    #5
    Thank you all for your help.
     
  6. macrumors 68030

    jared_kipe

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

Share This Page