mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-03-29 22:01:56 +02:00
make demo app for migrations initialize smoother
This commit is contained in:
@@ -174,23 +174,33 @@ class MigrationsDemoViewController: UIViewController {
|
|||||||
|
|
||||||
self.setDataStack(dataStack, model: model, scrollToSelection: true)
|
self.setDataStack(dataStack, model: model, scrollToSelection: true)
|
||||||
|
|
||||||
let count = dataStack.queryValue(From(model.entityType), Select<Int>(.Count("dna")))
|
let count = dataStack.queryValue(
|
||||||
|
From(model.entityType),
|
||||||
|
Select<Int>(.Count("dna"))
|
||||||
|
)
|
||||||
if count > 0 {
|
if count > 0 {
|
||||||
|
|
||||||
self.setEnabled(true)
|
self.setEnabled(true)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
|
for i: Int64 in 0 ..< 20 {
|
||||||
|
|
||||||
|
dataStack.beginAsynchronous { (transaction) -> Void in
|
||||||
|
|
||||||
|
for j: Int64 in 0 ..< 500 {
|
||||||
|
|
||||||
|
let organism = transaction.create(Into(model.entityType)) as! OrganismProtocol
|
||||||
|
organism.dna = (i * 500) + j + 1
|
||||||
|
organism.mutate()
|
||||||
|
}
|
||||||
|
|
||||||
|
transaction.commit()
|
||||||
|
}
|
||||||
|
}
|
||||||
dataStack.beginAsynchronous { [weak self] (transaction) -> Void in
|
dataStack.beginAsynchronous { [weak self] (transaction) -> Void in
|
||||||
|
|
||||||
for i: Int64 in 1 ..< 10000 {
|
transaction.commit { _ in
|
||||||
|
|
||||||
let organism = transaction.create(Into(model.entityType)) as! OrganismProtocol
|
|
||||||
organism.dna = i
|
|
||||||
organism.mutate()
|
|
||||||
}
|
|
||||||
|
|
||||||
transaction.commit { result -> Void in
|
|
||||||
|
|
||||||
self?.setEnabled(true)
|
self?.setEnabled(true)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user