यह प्रश्न ऐसा लगता है कि यह कई बार पहले पूछा गया है, लेकिन मुझे यकीन नहीं है कि मैंने सही उत्तर को एकत्रित किया है। तो यहाँ जाता है।कोर ऑब्जेक्ट आईडी बनाम स्थायी ऑब्जेक्ट आईडी
ऑब्जेक्ट आईडी का वर्णन ऐप्पल (डब्ल्यूडब्ल्यूडीसी 2012 सत्र 214) द्वारा संदर्भ-सुरक्षित, थ्रेड-सुरक्षित के रूप में किया गया है। तो मैंने इसका लाभ लेने के लिए कुछ समय मेरे कोड को परिवर्तित कर दिया। हालांकि, यह संदर्भ-सुरक्षित के रूप में प्रतीत नहीं होता है क्योंकि वे इसे ध्वनि बनाते हैं, क्योंकि hereCore Data: Do child contexts ever get permanent objectIDs for newly inserted objects? और अन्यत्र चर्चा की गई है, स्थायी आईडी नामक किसी चीज़ का अस्तित्व है।
के साथ इस स्थायी आईडी व्यापार के संबंध, मैं NSManagedObjectContext.h में देखा:
/* Converts the object IDs of the specified objects to permanent IDs. This implementation
will convert the object ID of each managed object in the specified array to a permanent
ID. Any object in the target array with a permanent ID will be ignored; additionally,
any managed object in the array not already assigned to a store will be assigned, based on
the same rules Core Data uses for assignment during a save operation (first writable store
supporting the entity, and appropriate for the instance and its related items.) Although
the object will have a permanent ID, it will still respond positively to -isInserted until
it is saved. If an error is encountered obtaining an identifier, the return value will be
NO.
*/
- (BOOL)obtainPermanentIDsForObjects:(NSArray *)objects error:(NSError **)error NS_AVAILABLE(10_5, 3_0);
तो मैं अपने कोड में इस के साथ समस्या हो रहा है। मेरे पास NSManagedObjectContexts (कहें, बी और सी) का पदानुक्रम है, और उनमें से केवल 1 वास्तव में एक सतत स्टोर से जुड़ा हुआ है (कॉल ए है)। तो, सी बी का बच्चा है, बी ए का बच्चा है। यदि मैं सी से एनएसएमएनेज्ड ऑब्जेक्ट बनाता हूं, और फिर प्राप्त करें टर्मिनेंट आईडी फोरऑब्जेक्ट्स, क्या यह वास्तव में स्थायी है? चूंकि .h फ़ाइल टिप्पणियां पढ़ती हैं जैसे कि बी को केवल पदानुक्रम दिखता है (पहले लिखने योग्य स्टोर इकाई का समर्थन करता है, और बच्चे-अभिभावक सेटअप में, परिवर्तन केवल 1 स्तर तक धकेलते हैं), ए
धन्यवाद अग्रिम।
मुझे एक बच्चे संदर्भ में वस्तुओं के लिए स्थायी आईडी प्राप्त करते समय "कोर डेटा एक गलती नहीं कर सका" प्राप्त हो रहा है। क्या आपको कभी पता चला कि क्या इसकी अनुमति नहीं है? –