I've noticed this with a few projects actually. The first was a small project I was writing from scratch that incorporated a datepicker. I noticed that no matter what I tried to do, it would always show as 2/12/1982. I'd try to override it by using something like this:
In place of setValue: I've also tried setDateValue: with the same results. No luck.
Also, in the Hillegass book's chapter 11 exercise, I saw the same behavior. In this particular example, he has the reader create a new class to override NSArrayController's newObject method.
CarArrayController.h
CarArrayController.m
When I run the application and create a new record, the datepicker still shows as 2/12/1982. Any ideas?
Code:
NSDate *currentDate = [NSDate date];
[myDatePickerObj setValue:currentDate];
In place of setValue: I've also tried setDateValue: with the same results. No luck.
Also, in the Hillegass book's chapter 11 exercise, I saw the same behavior. In this particular example, he has the reader create a new class to override NSArrayController's newObject method.
CarArrayController.h
Code:
#import <Cocoa/Cocoa.h>
@interface CarArrayController : NSArrayController {
}
@end
CarArrayController.m
Code:
#import "CarArrayController.h"
@implementation CarArrayController
- (id)newObject
{
id newObj = [super newObject];
NSDate *now = [NSDate date];
[newObj setValue:now forKey:@"datePurchased"];
return newObj;
}
@end
When I run the application and create a new record, the datepicker still shows as 2/12/1982. Any ideas?