2

I have in .h

@property (nonatomic) NSString *yourMom;

Then in .m

No synthesize! direct access in viewdidload:

_yourMom = @"Sally";

This works without synthesizing. Why?

GeneCode
  • 7,545
  • 8
  • 50
  • 85
  • 3
    `_yourMom` is automatically synthesized by the compiler, but you can custom it anyway you want – Tj3n Jan 18 '17 at 04:30
  • Ah. so it is auto-synthesized. good to know thanks Tj3n – GeneCode Jan 18 '17 at 04:32
  • 5
    Possible duplicate of [Under what conditions is @synthesize automatic in Objective-c?](http://stackoverflow.com/questions/9368676/under-what-conditions-is-synthesize-automatic-in-objective-c) – NobodyNada Jan 18 '17 at 04:32

1 Answers1

2
Objective-C @properties are synthesized by default when not explicitly implemented.

Unless you specify otherwise, the synthesized instance variable has the same name as the property, but with an underscore prefix. For a property called firstName, for example, the synthesized instance variable will be called _firstName.

Please read this document from Apple. It has comprehensive information that you need.

Martin Le
  • 719
  • 7
  • 14
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/low-quality-posts/14919331) – Jan Chrbolka Jan 18 '17 at 05:14
  • @JanChrbolka thank you for your recommendation. I have just edit my answer :) – Martin Le Jan 18 '17 at 05:32
  • @martinlee put comment in question this kind of answer dont update answer separately. – Himanshu Moradiya Jan 18 '17 at 05:42