I am trying to synthesize variables in my iPhone app with
@synthesize samples=_samples;
with samples declared as
@property (strong, nonatomic) NSMutableArray *samples;
However, I get a build error claiming that _samples does not exist. Why?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Are you trying to access the
_samplesfrom outside the implementation file? ivars generated through@synthesizeare not viewable by anything outside of the implementation where the@synthesizewas called. So if you do something like this……you will see an error. See here for more details: https://stackoverflow.com/a/8511046/251012
.
.
.
.
EDIT: All of the below is wrong. Left, so that the comments make sense
Are you declaring your ivar’s and are the names spelled correctly?
When you say something like…
…you need to make sure that you set the instance variable in your interface like so…
To be clear, when you say
foo=_foobar,foois the base name to auto-generate the getter/setter’s, and_foobaris the name of the ivar. If no ivar is declared,@propertywill auto-generate one of the same name.