quick way to check for duplicate values in Core Data

I need to quickly check to see if I have some duplicate values in CoreData. I am doing some background syncing and occasionally a dupe makes it into my system.

I have a ManufacturerID and an ItemID and I cannot have a duplicate value for both, example of bad data:

ManufacturerID   ItemID
35               IT001
35               IT001

So I would just want to know if that happened and maybe get a list of those ItemID's, then I need a way to figure out how to get rid of the dupes but this is a good start.

I just need a fast method figure out if they exist or not.

Answers


In my app I have a SynchManager that using NSoperations performs synch in background and store new records in the persistent sqlite store only if not alredy stored. Basically what I do is:

  1. execute a fetch request which retrieves a collections of stored ids (in my case these ids are strings representing urls)
  2. before insert a new object in the store I call a method like "shouldImportObject:", which basically test that the url is not already stored in the database. This is a simplified implementation sample:

    for (id objectID in ids) {
      if ([objectID isEqual:objectToImport.objectID]) {
         return NO;
      }
    }
    
    return YES;
    

Need Your Help

Running IntelliJ debugger with maven-antrun-plugin

java debugging maven intellij-idea

I have a libGDX project that is built using maven. I use the maven-antrun-plugin to run the project immediately after it's built, to make it so I can test new builds quickly from the IDE. A problem...

Disable/Enable Taskmanager with VBS

windows powershell vbscript taskmanager

Set WSHShell = WScript.CreateObject("WScript.Shell")

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.