开发者

Detecting duplicate entries in core data and removing them

I have started to work on a core data project. The data to store in the database comes from the server and I am able to store it successfully into coredata. However, each fetch is resulting in duplicate entries. What is the best way to check whether the data exists in core data and append only if the data is not found.

Here is my implementation so far:

for (NSDictionary *dict in array) {
        DatabaseManagement *mo = [NSEntityDescription insertNewObjectForEntityForName:@"Subscription" inManagedObjectContext:context];
        [mo setValuesForKeysWithDictionary:dict];

The array contains nested dictionary with keys corresponding to my entities attr开发者_JAVA百科ibute names.

I know I can use NSPredicate to achieve this but can someone provide sample code or some resources?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜