• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSArrayController help
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >The Problems with NSController (From: Aaron Hillegass <email@hidden>)
 >NSArrayController help (From: Mike Nowak <email@hidden>)

  • Prev by Date: Re: cocoa-dev digest, Vol 2 #3128 - 15 msgs
  • Previous by thread: NSArrayController help
  • Next by thread: Panther and Xcode Observations
  • Index(es):
    • Date
    • Thread