Questions tagged «nsfetchrequest»

3
如何从特定的对象ID获取核心数据对象?
我可以使用以下代码轻松地在Core Data中获取对象的ID: NSManagedObjectID *moID = [managedObject objectID]; 但是,是否有一种方法可以通过给它提供特定的对象ID将其从核心数据存储中移出?我知道我可以使用NSFetchRequest来做到这一点,就像这样: NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"Document" inManagedObjectContext:managedObjectContext]; [fetchRequest setEntity:entity]; NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(objectID = %@)", myObjectID]; [fetchRequest setPredicate:predicate]; 但是,我想以一种不会启动自己的获取请求的方式来执行此操作。有任何想法吗?
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.