Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Downloading data on a background thread above this line
- DispatchQueue.main.async {
- //Go through all the recently downloaded customers
- for (index, customer) in customers.enumerated() {
- //for each, add a new customer to core data
- self.createNewCustomer(customer: customer)
- }
- }
- func createNewCustomer(customer: Customer) {
- let newCustomer = Customers(context: self.context)
- ...
- //Convert time to seconds using a method in a different view controller.
- let seconds = CustomerViewController().secondsFromDate(date: date)
- //Save to core data and repeat
- appDelegate.saveContext()
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement