In my code, I have about five @property statements; when I go to @synthesize = ... them, some give me choices (of the property name) in the dropdown menu of objects, and some do not. I also find that if I don’t get all of the properties changed to _property in my methods, it makes no difference in execution; the app still works.
Why does the app still run whether or not the property name has an underscore as a prefix?
You should use
@synthesize iVar = _iVar;, but maybe soon you won’t need to synthesize at all 😉I would say that the options given by Xcode are just the code completion being a bit buggy.
Strictly speaking, the name you use doesn’t matter at all (as long as there aren’t any collisions),
@synthesize iVar = i_va_R;is perfectly legal, so is:All you are saying is that you want the property to be backed by an instance variable with the given name. If you never access the instance variable directly (always use
self.iVarrather thaniVaror_iVar) then it doesn’t really matter at all what you use, it only matters to the rest of the code if you want to access the iVar directly.Just to clarify a little more, here is an example of of how the above could be implemented without using properties:
(PS: I am using
ints to avoid dealing with memory management, the same applies to objects too though)