cocoa - Thread-safe unique entity instance in Core Data -
I have a message unit that has messageID assets, I want to make sure that only one installation with a message id To be given the message in SQL, I just put a unique barrier in the messageID column, but I do not know how to do it with core data. I believe this can be done in the data model, so how do you know about it?
My initial idea is to use an authentication method to fetch one reference to the ID of NSManagedObject for ID, if it finds anything by itself, and if so, then the verification fails. I suspect this will work - but I am concerned about the performance of something like this. I went through a lot of efforts to reduce the required fetch requests for the entire import routine, and it seems a bit more valid after each fetching it for a new message unit. I can get all pre-existing objects and identify all the new objects that I need to insert into the store using only two fetch queries before I import and connect everything together to be real Work. With this, add each one update or put them apart - which will eliminate any of the performance benefits made by pre-processing import data in the first place!
The main reason for this is that the importer can run several batches on many theaters and it may contain some overlapping / duplicate data, which eventually result in only one object in the store and the entries Should not be copied Is there a proper way to do this and is I asking for understanding the core data?
The only way to guarantee uniqueness is to do a fetch, fortunately you just have a -countForFetchRequest: Error:
and check to see if it is zero or not. This is the least expensive way to guarantee specificity at this time.
You may possibly meet it in validation or run that data in the processing loop. Personally, I will make it above the creation of the NSManagedObject
so that you do not have any unnecessary allocs when a record is already present.
Comments
Post a Comment