I am stuck in this book I am reading and its about accessor methods and the reason I am here is because I don't understand the code because the author doesn't explain it very well.
All I am asking is just some notes beside each line telling me what is happening in all this code
Code:
@interface Car : NSObject
{
Engine *engine;
Tire *tires[4];
}
- (Engine *) engine;
- (void) setEngine: (Engine *) newEngine;
- (Tire *) tireAtIndex: (int) index;
- (void) setTire: (Tire *) tire
atIndex: (int) index;
- (void) print;
@end // Car
Code:
@implementation Engine
- (Engine *) engine
{
return (engine);
} // engine
- (void) setEngine: (Engine *) newEngine
{
engine = newEngine;
} // setEngine
Code:
Engine *engine = [Engine new];
[car setEngine: engine];
NSLog (@"the car's engine is %@", [car engine]);
Code:
- (void) setTire: (Tire *) tire
atIndex: (int) index;
- (Tire *) tireAtIndex: (int) index;
Code:
@implementation Tire
- (void) setTire: (Tire *) tire
atIndex: (int) index
{
if (index < 0 || index > 3) {
NSLog (@"bad index (%d) in setTire:atIndex:",
index);
exit (1);
}
tires[index] = tire;
} // setTire:atIndex:
- (Tire *) tireAtIndex: (int) index
{
if (index < 0 || index > 3) {
NSLog (@"bad index (%d) in "tireAtIndex:",
index);
exit (1);
}
return (tires[index]);
} // tireAtIndex:
Code:
Tire *tire = [Tire new];
[car setTire: tire
atIndex: 2];
NSLog (@"tire number two is %@",
[car tireAtIndex: 2]);
I know this is a lot of code but I am really stuck.
If this is not needed in iPhone Dev PLEASE tell me

Thanks
Arc