Display data from NSArray in NSTableView
-
11-09-2019 - |
Question
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!
Solution
You could use it as the data for an NSArrayController which you bind to the NSTableView.
OTHER TIPS
Looks like you need to read into bindings.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow