#import <Cocoa/Cocoa.h>
#import "Greeter.h"

void greetTheWorld(void) {
    Greeter * worldGreeter = [[Greeter alloc] init];
    [worldGreeter sayHello];
    [worldGreeter release];
}

void greetAPerson(NSString * personName) {
    Greeter * personGreeter = [[Greeter alloc] initWithName:personName];
    [personGreeter sayHello];
    [personGreeter release];
}

// START:code.objects.callaccessors
void greetAnotherPerson(NSString * personName){
    Greeter * changingGreeter = [[Greeter alloc] init];
    NSLog(@"Right now the greetee's name is %@", changingGreeter.greetee); // <label id="code.objects.get1"/>
    [changingGreeter sayHello];
    changingGreeter.greetee = personName; // <label id="code.objects.set1"/>
    NSLog(@"Right now the greetee's name is %@", [changingGreeter greetee]);  // <label id="code.objects.get2"/>
    [changingGreeter sayHello];
    [changingGreeter setGreetee:@"world (again)"]; // <label id="code.objects.set2"/>
    [changingGreeter sayHello];
    [changingGreeter release];
}
// END:code.objects.callaccessors

//START:code.objects.calling
int main(int argc, char *argv[])
{
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    //START_HIGHLIGHT
    greetAnotherPerson(@"Daniel");
    // END_HIGHLIGHT
    [pool release];
    return NSApplicationMain(argc,  (const char **) argv);
}
//END:code.objects.calling