Hi all!
Well I am in Chapter 9 and the code entered is not working. I am thinking that this must be another Objective-C 2.0 example and I only have Objective C 1.0.
Here is the method:
Now here is the problem, in the Create the object part: employeeController is defined in the header file as NSArrayController. However at this point it is nil. (I just added a test before it create p). Where should the connection be made for employeeController.
Here is the header:
So at the moment I am stuck in the book. I thank you all in advance for the help. You guys (or gals) are great and I thank you for your patience.
-Don
Well I am in Chapter 9 and the code entered is not working. I am thinking that this must be another Objective-C 2.0 example and I only have Objective C 1.0.
Here is the method:
Code:
- (IBAction)createEmployee:(id)sender
{
NSWindow *w = [tableView window];
// Try to end any editing that is taking place
BOOL editingEnded = [w makeFirstResponder:w];
if (!editingEnded)
{
NSLog(@"Unable to end editing");
return;
}
NSUndoManager *undo = [self undoManager];
// Has an edit occured already in this event?
if ([undo groupingLevel])
{
// Close the last group
[undo endUndoGrouping];
// Open a new group
[undo beginUndoGrouping];
}
// Create the object
Person *p = [employeeController newObject];
// Add it to the content array of 'employeeController'
[employeeController addObject:p];
[p release];
// Re-sort (in case the user has sorted a column)
[employeeController rearrangeObjects];
// Get the sorted array
NSArray *a = [employeeController arrangedObjects];
// Find the object just added
int row = [a indexOfObjectIdenticalTo:p];
NSLog(@"starting edit of %@ in row %d", p, row);
// Begin the edit in the first column
[tableView editColumn:0
row:row
withEvent:nil
select:YES];
}
Now here is the problem, in the Create the object part: employeeController is defined in the header file as NSArrayController. However at this point it is nil. (I just added a test before it create p). Where should the connection be made for employeeController.
Here is the header:
Code:
#import <Cocoa/Cocoa.h>
@class Person;
@interface MyDocument : NSDocument
{
NSMutableArray *employees;
IBOutlet NSTableView *tableView;
IBOutlet NSArrayController *employeeController;
}
- (IBAction)createEmployee:(id)sender;
@end
So at the moment I am stuck in the book. I thank you all in advance for the help. You guys (or gals) are great and I thank you for your patience.
-Don