简体   繁体   中英

Swift 3 Core Data - How to save context synchronously?

I need to import data into one enity, and then another entity that has a relationship with the first. The problem is that it crashes on the second entity because the the save is not complete on the first. How should I best deal with this in Swift 3 / Xcode 8 / IOS 10?

self.viewContext.save()  

I need to make sure the save is complete before importing the second entity.

我发现它是同步保存的,但我必须在每一行之后保存,否则它只是无法正常工作。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM