Why does Xcode 4 automatically generate an instance variable?

I am coming from C # development and have just started to study Objective-C and Xcode 4. As far as I understand, "@synthesize" replaces getter / setter methods for properties if you do not need to check / control the values ​​that are read or written.

But why does Xcode 4 automatically create an instance variable for me?

It would not be enough:

@synthesize myProperty;

instead:

@synthesize myProperty = _myProperty;

?

Why do I want to use / have an instance variable instead of the actual property if I don't have / need any getters or setters?

Thanks in advance!

Memphiz

EDIT:

, @synthesize /, : = _myProperty;? , "myProperty" ? , "_myProperty", , , . , _myProperty. @synthesize, , . , / ?

:

MattyG!

+5
2

, . , :

@synthesize myProperty = _myProperty;

:

_myProperty = something;

, :

self.myProperty = something;

, . :

myProperty = something;  //this won't compile

.

+14

, DECLARE .h, . , , , ... . , @synthesize. , .

#

private int _int1;
public int int1 {
  get { return _int1; }
  set { _int1 = value; }
}

, # ,

public int int1 { get; set; }

, "_int1", # . @synthesize , , , .

. , C. , #, get {} set {}. C , , - "", .

, , .h

int myVar;
...
@property(nonatomic, assign) int myVar;

getters seters .m

-(int)myVar {
  return myVar;
}

-(void)setMyVar:(int)newVar {
  myVar = newVar;
}

@synthesize, getter setter

-2

All Articles