core data - Update/Edit coreData managed object -


i'm trying edit coredata object when user clicks on cell in uitableview based on cell.accessorytype show if item has been clicked. here current code.

- (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath {  uitableviewcell *cell = [tableview cellforrowatindexpath:indexpath];  nsmanagedobject *itemtoupdate = [groceryarray objectatindex:indexpath.row]; nslog(@"updating: %@", itemtoupdate);  if (cell.accessorytype == uitableviewcellaccessorycheckmark) {     cell.accessorytype = uitableviewcellaccessorynone;     itemtoupdate.purchased = no; }else {     cell.accessorytype = uitableviewcellaccessorycheckmark;     itemtoupdate.purchased = yes; }  // commit change. nserror *error; if (![managedobjectcontext save:&error]) {     // handle error.     nslog(@"saving changes failed: %@", error);  } } 

it seems selecting right object because nslog() show correct item when try update using dot notation e.g. "itemtoupdate.purchased = yes;" compiler throws error "request member 'purchased' in not structure or union".

i know i'm doing wrong (my first project in xcode) - advice appreciated!

thanks

have tried:

[itemtoupdate setvalue:[nsnumber numberwithbool:no] forkey:@"purchased"] 

form?

i subclass nsmanagedobject , dot notation works declared properties. might try "older" notation see if works.


Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -