NSManagedObjectContext 异步还是同步保存更改?
NSManagedObjectContext 异步还是同步保存更改?
如果异步,那么我如何等待保存更改?
The NSManagedObjectContext saves changes asynchronously or synchronously?
If asynchronously, then how can I wait for saving changes?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
同步。
您可以在
save
调用之后放置您想要在保存后运行的任何代码。NSManagedObject
上的方法-(void)willSave
和-(void)didSave
允许您在保存之后/之前对模型类执行行为。如果您使用的是 Mac,您还可以查看名为 NSManagedObjectDidSaveNotification
Synchronously.
You can put any code you want to run after saving just after the
save
call.The methods
-(void)willSave
and-(void)didSave
onNSManagedObject
allow you to perform behaviour on your model class after/before save.If you're on the Mac you can also watch for a notification called NSManagedObjectDidSaveNotification