0

I have hit a bit of a brick wall and am looking for some help with a Cocoa OSX app i am trying to put together.

I have a single entity in core data, which is being populated from a Dictionary pulled from the net. The core data objects are then displayed in a TableView using bindings and an array controller.

Now, i want the ability to detect the selected object in the table, then when a button is pressed in the GUI for it to update a specific attribute of the selected entity.

This is where i have hit a brick wall, lots of info on how to pull/update objects when pulled with a predicate, and lots on how to bind directly to the array controller to add/remove/delete. But nothing on how to update a hidden property with a value that's stored in code.

Any help/pointers greatly appreciated, especially if it's OSX rather than iOS orientated!

Thanks

Gareth

Gareth Jeanne
  • 1,410
  • 2
  • 19
  • 35

1 Answers1

0

Actually i managed to work this out.

First i implemented a function that gets the current selected object from the array controller and returns it.

-(Tweet*)getCurrentSelectedTweet {
    if ([[self.twitterClientsController selectedObjects] count] > 0) {
        return [[self.twitterClientsController selectedObjects] objectAtIndex: 0];
    } else {
        return nil;
   }
}

Then i use this function bound to an IBAction to call it and modify the object:

- (IBAction)approveTweet:(id)sender {
    Tweet *selectedTweet = [self getCurrentSelectedTweet];
    if (selectedTweet) {
        selectedTweet.approved = [NSNumber numberWithBool:TRUE];
        NSLog(@"%@", selectedTweet);
    }
}
Gareth Jeanne
  • 1,410
  • 2
  • 19
  • 35