This is a matter of preference / convention for some. Default:
@property (assign) NSString * myString;
... then follow:
@synthesize myString;
... will give you three things. You get a setter method that can be accessed as self.myString = @"newValue" or [self setMyString:@"newValue"] , a getter method that can be accessed as NSString* temp = self.myString or NSString* temp = [self myString] , and an instance variable called myString , which can be accessed directly inside your class (that is, without going through getter and setter) and is used to set and get the value of the property and which is used internally to return the property.
If you like, you can do @synthesize myString = someOtherVarName , and then you still get the setters and getters as before, but instead of the myString instance variable, the someOtherVarName instance someOtherVarName used to return the property, and no myString variable is created.
So why use a more detailed syntax? There is never a case when you do this, but some people prefer to do this when dealing with properties declared with retain or copy . The reason for this is that setting the declared retain or copy property through its generated installation method affects the account of saving the object that is set / not set. The same thing happens when directly accessing an instance variable.
Thus, by smoothing the instance variable to something else, you can make the difference in the code line by line “everything that xxx.myString = Y does, changing the save counter, while everything that someOtherVarName = Y does not” . Again, this does not need to be done, but some people prefer to do it.
source share