简体   繁体   中英

iPhone Core Data - How to remove NSManagedObject from context?

CustomManagedObject *newObject = (CustomManagedObject *)[NSEntityDescription insertNewObjectForEntityForName:@"Substation" inManagedObjectContext:[[DatabaseHelper instance] context]];

I make a new object, using the line above. However sometimes i dont want to save that object to permanent data store, i just want to remove it from context. Is there some kind of method like removeObject: object fromContext: context?

Did you check the documentation? The method is called deleteObject :

[[[DatabaseHelper instance] context] deleteObject:newObject]; 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM