Created
May 3, 2016 18:34
-
-
Save frr149/edd4d33a68019052e5916c93dd78c7ef to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func backgroundLoad(){ | |
if let coord = self.stack.context.persistentStoreCoordinator{ | |
let bckgContext = NSManagedObjectContext(concurrencyType: .PrivateQueueConcurrencyType) | |
bckgContext.persistentStoreCoordinator = coord | |
// This will run in the background | |
bckgContext.performBlock(){ | |
for i in 1..<100{ | |
let nb = Notebook(name: "New notebook \(i)", context: bckgContext) | |
for j in 1..<100{ | |
let note = Note(text: "Type something \(j)", context: bckgContext) | |
note.notebook = nb | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment