- (id)tableView:(NSTableView *)tableview
objectValueForTableColumn:(id)column
row:(int)row
{
ChildObject *child = [childrenArray objectAtIndex:row];
if ( [[column identifier] isEqualToString:@"name"] ) {
return [child name];
}
if ( [[column identifier] isEqualToString:@"age"] ) {
return [child age];
}
......
The code above is from this page:
http://developer.apple.com/library/ios/#documentation/cocoa/conceptual/KeyValueCoding/Articles/Overview.html
I am unable to understand what [child name] is.
Is the instance variable of ChildObject class being sent a message “name” which is somehow supposed to bring up a name from an array object?
[child name]sends a message called “name” tochildwhich is an instance of the ChildObject class. The ChildObject class implements a method namedname, which (presumably) returns an NSString whose value is equal to the value of child’s name instance variable. The only way an array object is involved is thatchilditself is obtained by pulling it fromchildrenArraywhich is an array of ChildObject instances.