views:

50

answers:

2

I have a class called Chair.

I have a view controller that contains an object of type Chair.

At some point, I am trying to assign my viewcontrollers instance to another instance of a Chair object as such:

[viewcontroller setChair: thisChair];

My setter looks as such:

- (void) setChair:(Chair *)thisEntryChair;
{
        myVCChair = thisEntryChair; 
}

I am getting this error:

[setChair:]: unrecognized selector sent to instance 

whether I use a setter function or plainly as such or use a setter:

viewcontroller.myVCChair = thisEntryChair;

This approach, if I have done it in the same manner as I have other variables which I believe I have, I assume is having issues as this is a custom object not an inbuilt one?

Help!

+2  A: 

I think the class name and the field name being the same might be a problem. Try renaming your member variable aChair or something to see if it works. Then you can choose a name you like better.

UPDATE BASED ON QUESTION EDIT:

@synthesize shouldn't be used if you want your own setter. The setter should be named

 -(void) setmyVCChair: (Chair*) aChair {
     myVCChair = aChair;
 }

Then you can use viewcontroller.myVCChair = anotherChair

Lou Franco
bump for email notification to my response above
Lance
I am performing it like this, and yet it continues to crash :(I am performing it in the EXACT same manner that I do it to an NSURL contained in the same class.This is why I figured it might be something odd with custom objects being used vs inbuilt NSURL etc
Lance
A: 

so in your example the code would be:

[viewcontroller setChair:somechair];

or

viewcontroller.chair = someChair;

The internal class ivar myVCChair isn't exposed.

NWCoder
arg, I'm sorry!! When I posted this question I made a few mistakes in trying to generalise my code... Please see edited version.
Lance
I don't entirely understand your answer sorry. What do you mean by the internal class ivar myVCChair isn't exposed?I have declared it as a property and synthesize and hence it is exposed?Apologies, I am not yet up to speed on all the lingo
Lance