开发者

TableView commitEditing method

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?

 NSManagedO开发者_如何学PythonbjectContext *context = [fetchedResultsController managedObjectContext];
 [context deleteObject:[fetchedResultsController objectAtIndexPath:indexPath]];

This is where the object is deleted, I need to know what item has been deleted in a string.


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"]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜