Just starting to learn Objective-C... it hurts my head but it's fun at the same time, so I guess it's not too bad.
I just started on a section of a book about the OOP part of Objective-C, and I had two questions:
1. It says in the book that:
If that's true, why is it necessary to do the @interface part at all?
2. Also, I notice that in the sample code, they do this:
They do this for other parts of the implementation(?) as well, but the variable "c" is "b", "a", and so on. I understand that this is done as to not cut off the scope of the old variable, but does it matter if the variable I use is the same as another part of the implementation?
For example:
What problems would be caused by this?
Thank you in advance for your help
I just started on a section of a book about the OOP part of Objective-C, and I had two questions:
1. It says in the book that:
The definitions of the individual methods are next. They dont have to appear in the same order as they do in the @interface directive. You can even define methods in an @implementation that dont have a corresponding declaration in the @interface. You can think of these as private methods, used just in the implementation of the class.
NOTE
You might think that defining a method solely in the @implementation directive makes it inacces- sible from outside the implementation, but thats not the case. Objective-C doesnt really have private methods. There is no way to mark a method as being private and preventing other code from calling it. This is a side effect of Objective-Cs dynamic nature.
If that's true, why is it necessary to do the @interface part at all?
2. Also, I notice that in the sample code, they do this:
Code:
- (void) setFillColor: (ShapeColor) c
{
fillColor = c;
} // setFillColor
They do this for other parts of the implementation(?) as well, but the variable "c" is "b", "a", and so on. I understand that this is done as to not cut off the scope of the old variable, but does it matter if the variable I use is the same as another part of the implementation?
For example:
Code:
- (void) setFillColor: (ShapeColor) c
{
fillColor = c;
} // setFillColor
- (void) setBorderColor: (BorderColor) c
{
borderColor = c;
} // setBorderColor
What problems would be caused by this?
Thank you in advance for your help