Your properties almost always have a backing variable. What
@synthesize searchBar = _searchBar;
does is declare that the backing variable for your search bar will be called _searchBar
. This allows you to decouple the name of the property from the name of your variable. In fact, if you don’t use @synthesize
you don’t need to have a backing variable at all.
As for why people do this, everyone has different reasons. Personally, I do it to
- avoid clashes with variable names and
- make it clear when I’m using a local variable and when I’m using an instance variable.