Binding NSTableView via NSArrayController to yapdatabase

14 views
Skip to first unread message

rdu...@comcast.net

unread,
Jan 23, 2016, 10:58:53 AM1/23/16
to YapDatabase
Hi All,

I have sorted out much of the code now for my Mac app, making changes from iOS methods etc.

Now I am working on getting the tableview to cary the database records. Something not quite right there yet but before proceeding with working with the delegate methods and records, Is there a way to use bindings on array controller to the yap context and model key paths?

I have done this with Core Data before as it has the option for managedObjectContext 

Is there a way to do this with yapdatabase?

Thanks,  Rob


janice Redman

unread,
Jan 24, 2016, 11:26:18 AM1/24/16
to YapDatabase

Addendum: Ok - I don't see how this would be possible so am trying the delegate methods but can't get records to return in os x NStableView. I have gone through DatabaseManager.m changing the classes to my own for the view methods. The count for rows isn't returned from mappings.



//in DatabaseManager.m I changed all pertinent objects to RDFBirthday's

// the methods are getting called for group, sorting etc.. but something is missing


  //in awake from nib...

databaseConnection = MyDatabaseManager.uiDatabaseConnection;

[self initializeMappings];


- (void)initializeMappings

{

[databaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {

if ([transaction ext:Ext_View_Order])

{

mappings = [[YapDatabaseViewMappings alloc] initWithGroups:@[@""] view:Ext_View_Order];

[mappings updateWithTransaction:transaction];

}

else

{

// The view isn't ready yet.

}

}];

}


- (NSInteger)numberOfRowsInTableView:(NSTableView *)view{

//returns 0 rows only

return [mappings numberOfItemsInSection:0];

}


- (RDFBirthday *)todoAtIndexPath:(NSIndexPath *)indexPath

{

__block RDFBirthday *todo = nil;

[databaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {

todo = [[transaction ext:Ext_View_Order] objectAtIndexPath:indexPath withMappings:mappings];

}];

return todo;

}


- (id)tableView:(NSTableView *)view objectValueForTableColumn:(NSTableColumn *)col row:(NSInteger)row

{

NSLog(@"objectvalueForTable called here"); //never called!

NSIndexPath *indy = [NSIndexPath indexPathWithIndex:row];

RDFBirthday *birthday = [self todoAtIndexPath:indy];

if ([[col identifier] isEqualTo: @"name"]){

return birthday.bname;

}

}

Reply all
Reply to author
Forward
0 new messages