views:

210

answers:

1

hi, i got a tableview which is the one by default when you create a tableview using core data application, and there is this fetching managed object i don't really understand, anyway when the user delete something from the tableview i need to take the object that is deleted and gets it as a String, it is possible?

 NSManagedObjectContext *context = [fetchedResultsController managedObjectContext];
 [context deleteObject:[fetchedResultsController objectAtIndexPath:indexPath]];

this is where the object is deleted, i need to know what item as been deleted in a string. Thank you

+1  A: 

Well, [fetchedResultsController objectAtIndexPath:indexPath] refers to the object that is being deleted (since it's being passed to deleteObject:). Unfortunately, I can't help you any farther than that, because I can't be sure how you want to create a string from the object.

But I can guess that you probably wish to access some string attribute of the object (perhaps a name or ID?) To do this you can use valueForKey:. So, to create, for example, a string out of the deleted object's name (assuming, of course, that the object has an attribute called "name"), you could use:

[[fetchedResultsController objectAtIndexPath:indexPath] valueForKey:@"name"]
andyvn22
ok thx but when i use what you said, it gave me the good object but with some non-understandable things. Like this : my object is supose to be Beer 5% 5oz for exemple and it gave me : Beer 222042722134z
the1nz4ne