Delete an object in core data

后端 未结 3 1679
清歌不尽
清歌不尽 2021-02-06 00:26

I have an entity in my core data model like this:

@interface Selection : NSManagedObject

@property (nonatomic, retain) NSString * book_id;
@property (nonatomic,         


        
3条回答
  •  生来不讨喜
    2021-02-06 00:54

    In addition to Mike Weller and flexaddicted, after calling [context deleteObject:currentObj]; you need to save: context:

    NSError *error = nil;
    [context save:&error];
    

    As from documentation:

    Just as a new object is not saved to the store until the context is saved, a deleted object is not removed from the store until the context is saved.

    That made matter in my case.

提交回复
热议问题