views:

384

answers:

2

Hi all,

I have a problem, and I reckon there's a really straightforward solution to it, but I can't fathom it out!

I have this piece of code:

NSManagedObjectContext * context  = [[NSApp delegate] managedObjectContext];
    NSManagedObjectModel   * model    = [[NSApp delegate] managedObjectModel];
    NSDictionary           * entities = [model entitiesByName];
    NSEntityDescription    * entity   = [entities valueForKey:@"Post"];

    NSPredicate * predicate;
    predicate = [NSPredicate predicateWithFormat:@"date < %@", [NSDate date]];

    NSSortDescriptor * sort = [[NSSortDescriptor alloc] initWithKey:@"date" ascending:YES];
    NSArray * sortDescriptors = [NSArray arrayWithObject: sort];

    NSFetchRequest * fetch = [[NSFetchRequest alloc] init];
    [fetch setEntity: entity];
    [fetch setPredicate: predicate];
    [fetch setSortDescriptors: sortDescriptors];

    NSArray * results = [context executeFetchRequest:fetch error:nil];
    [sort release];
    [fetch release];

This returns the specified data in an Array. I now want to display this data in a NSTableView.

How would I go about doing this?

Thanks!

+4  A: 

You could use it as the data for an NSArrayController which you bind to the NSTableView.

Abizern
More specifically, you bind the array controller to the owner of the array, and one or more columns of the table view to the arranged objects of the array controller.
Peter Hosey
A: 

Looks like you need to read into bindings.

Seymour Cakes