开发者

Remove an Object/Row from a Core Data Entity

开发者 https://www.devze.com 2023-04-08 16:00 出处:网络
There are a couple answers similar to this (Like deleting an entire entity). But none that have worked for me. I am just looking for simple way to fetch the object I want to delete using NSPredicate a

There are a couple answers similar to this (Like deleting an entire entity). But none that have worked for me. I am just looking for simple way to fetch the object I want to delete using NSPredicate and then delete only that object. I only want to delete one object/row. It should be fairly simple code, nothing too complicated. I would provide my code but I am pretty sure it won't help because it isn't even close to being complete or even workin开发者_开发知识库g.


EntityToDelete *entity = (EntityToDelete *)[NSEntityDescription insertNewObjectForEntityForName:@"EntityToDelete" inManagedObjectContext:self.managedObjectContext];  

NSError *error;  

[self.managedObjectContext deleteObject:entity];

if (![self.managedObjectContext save:&error]) {



}
0

精彩评论

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

关注公众号