Re: NSArrayController help
Re: NSArrayController help
- Subject: Re: NSArrayController help
- From: mmalcolm crawford <email@hidden>
- Date: Fri, 31 Oct 2003 22:53:39 -0800
On Oct 31, 2003, at 12:06 PM, Mike Nowak wrote:
I am exploring using NSArrayController to help me manage a table in my
interface. I have an object that represents annual data. My table
displays the year as the first item in the table. When a person adds a
new item to my array, I wanted to find the maximum year that exists
and prefill in that year + 1 by initializing the year instance
variable for that object. [...]
I guess I can subclass NSArrayController and so I can override
addObject and set the year for the new item. Is the best way to do it?
Thanks!
Subclass NSArrayController and override - (id)newObject
<
http://homepage.mac.com/mmalc/CocoaExamples/AddaYear.zip>
mmalc
@implementation YearAddArrayController
- (id)newObject
{
NSCalendarDate *year = [self
valueForKeyPath:@"email@hidden"];
NSCalendarDate *yearPlusOne = [year dateByAddingYears:1 months:0
days:0 hours:0 minutes:0 seconds:0];
id newObj = [super newObject];
[newObj setValue:yearPlusOne forKey:@"year"];
return newObj;
}
@end
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.