For Objective-C, in the following header file:
@interface Peg : NSObject {
char color;
}
@property char color;
I wonder if the member variable is already said to be a char type, then why does the @property has to repeat it? (or else it won’t compile). Couldn’t the compiler tell that it is char? It couldn’t be anything else, could it?
That is because generaly properties don’t have to be related to any declared instance variable of your class. You may have a property and not include a variable into your class header. That’s why you have to declare it’s type.
Using properties instead of variables makes your headers clean, hiding the implementation.
So, you can just declare a property and then
@synthesizeit