【发布时间】:2019-09-20 04:21:12
【问题描述】:
我有一个 NSManagedObject's 数组,我想将它们复制到一个新数组中,以便对其进行操作,而不是在用户完成后保存更改。
数组:
var origQuestions: [Questions]?
这就是我从 CoreData 检索数据的方式:
self.origQuestions = MainDb.sharedInstance.randomQuestions(entity: "Questions", count: self.questionToShow)
这是我在 Objective-C 中需要的,但我想知道如何在 Swift 4 中这样做:
NSMutableArray *questionsCopy = [[NSMutableArray alloc] initWithArray:self.origQuestions copyItems:YES];
【问题讨论】:
-
您能否通过显示一些您迄今为止尝试过的代码来缩小您的问题范围?
-
@Christophe 我已经编辑了我的问题。请检查。谢谢!
-
好的。对this question 的快速回答有帮助吗?
标签: arrays swift core-data copy swift4