PDA

View Full Version : @synthesize problems




blue-lion
Dec 3, 2010, 02:29 PM
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?



chown33
Dec 3, 2010, 02:41 PM
Reread the reference docs on properties, paying particular attention to the capitalization algorithm for mapping property names onto method names.

ulbador
Dec 3, 2010, 02:45 PM
I've read that setter methods are created this way so,when i use the function below, it should work...right?

[object1 setfillColor 2] ;


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

PatrickCocoa
Dec 3, 2010, 02:53 PM
I've read that setter methods are created this way so,when i use the function below, it should work...right?

[object1 setfillColor 2] ;



can anybody help?

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

blue-lion
Dec 3, 2010, 03:27 PM
Thank you all for your help.

jared_kipe
Dec 4, 2010, 12:43 AM
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?

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