I am trying to duplicate existing NSManagedObject and related sub-commodities in core data. I can not find an easy way to do this.
I have an NSArrayController that is populated with core data databases. I want to take the object on the selection index and make a deep copy, keeping it related to the same original object and copying all the child objects. Want to do
Any help is appreciated!
Thanks for the link TechZen I used the sample code from that site and used this calling code:
Rules SetsVersion * object = [[ruleSetVersionArrayController selected objects ] LastObject]; NSString * parentEntity = @ "RuleSet"; Set rule warson * newObject = (Rule SetsVersion *) [Self Copy Object: Object To Contact: [Self-Managed Object Contain] Parents: Parent Entity]; [New object settersetifydetect: [[NSDT Elok] Init]]; [New Object Settlement SettingLostodified Rating: [[NSDT Alok] Init]]; [New object setRuleSet: object.ruleSet]; NSError * error; If ([managedObjectContext save: & error] == no) {[NSAPP present error: error]; }
It is quite involved. See this answer and sample code linked to it:
Comments
Post a Comment