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

Python - How to replace numbers variables

python string

How to replace numbers variables ?

How to get rowIndex in extjs widget column

javascript extjs extjs6

I need a button in a widget column to know its rowIndex in an ExtJS 6 panel.grid, so that on button click it can use that functionality. I know I can pull that information from the renderer functi...

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.