I am following an exercise from Aaron Hillegass's Cocoa book - chapter about Core Data. I have a document-based application that saves car(s) data into an array controller, it then uses bindings... The problem is that I have a date picker, and I want to initialize it to today's date as soon as a new car is added, so we're subclassing NSArrayController's newObject method. But, it always shows 2/12/1982! The NSLog inside the newObject method is not called. What am I (or book) missing?
CarArrayController.h
#import <Foundation/Foundation.h>
@interface CarArrayController : NSArrayController
@end
CarArrayController.m
#import "CarArrayController.h"
@implementation CarArrayController
- (id)init //this is not called!
{
self = [super init];
if (self) {
NSLog(@"in init");
}
return self;
}
-(id)newObject { // not called either
id newObj = [super newObject];
NSDate *now = [NSDate date];
[newObj setValue:now forKey:@"datePurchased"];
NSLog(@"yep");
return newObj;
}
@end
MyDocument.xib
Has an instance of NSArrayController, its Custom Class name is set to CarArrayController.
PS: For my Array Controller in MYDocument.xib, "Prepares Content" button is checked, so automaticallyPreparesContent should be set to YES...?