How to Perform a Lightweight Core Data Migration

Discussion of the official tutorials published on raywenderlich.com. Please only discuss the official tutorials here - for general questions, use the General Discussion forum instead.

How to Perform a Lightweight Core Data Migration

Postby rwenderlich » Thu Feb 14, 2013 11:00 am

This is the official thread to discuss the following blog post: How to Perform a Lightweight Core Data Migration
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
Ray Wenderlich
Blog: http://www.raywenderlich.com
Twitter: http://twitter.com/rwenderlich
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
User avatar
rwenderlich
Site Admin
 
Posts: 1776
Joined: Thu Dec 23, 2010 4:14 pm
Has thanked: 26 times
Been thanked: 186 times

Re: How to Perform a Lightweight Core Data Migration

Postby alnp1987 » Thu Feb 14, 2013 6:15 pm

Thanks for the great tutorial Scott. I have one question. Can you explain why you decided to pass in an NSManagedObject to the DetailViewController instead of an NSManagedObjectContext when creating a new Thought? I understand that passing the managed object requires to implement a rollback functionality as you mentioned if the users cancels, but wouldn't be more efficient to have DetailViewController create the managed object and save it only when the user taps a save button? If not, how would one go about implementing the rollback functionality?
alnp1987
n00b
 
Posts: 1
Joined: Thu Nov 03, 2011 1:13 am
Has thanked: 0 time
Been thanked: 1 time

Re: How to Perform a Lightweight Core Data Migration

Postby scotteg » Fri Feb 15, 2013 2:35 pm

@alnp1987 Thanks, glad you liked it! You could delay creating a new managed object until when Save is tapped. This would involve caching the data, e.g., in a dictionary in the create/edit view controller, and then accessing that dictionary in a delegate in a method such as someDetailViewControllerDidFinish, where you would proceed with creating a new managed object and assigning the values. To implement rollback, you would first create and set an undo manager on your managed object context when you instantiate it, and then to rollback, just call rollback on your managed object context in your delegate in a method such as someDetailViewControllerDidCancel. These are great questions, which do go beyond the scope of this tutorial, though. Hopefully my brief comments help to steer you in the right direction. Good luck!
User avatar
scotteg
iOS Tutorial Team Member
 
Posts: 14
Joined: Sun May 01, 2011 11:15 pm
Location: Greater St. Louis area
Has thanked: 3 times
Been thanked: 1 time

Re: How to Perform a Lightweight Core Data Migration

Postby johnheb » Fri Feb 22, 2013 3:49 am

Great Tutorial especially the explanation.

I have a business app and I am using iCloud which is working fine. However, lightweight migration and iCloud don't seem to want to play together. Your thoughts?

Thanks

John
johnheb
Baby Hacker
 
Posts: 7
Joined: Mon Oct 08, 2012 12:07 pm
Has thanked: 1 time
Been thanked: 1 time

Re: How to Perform a Lightweight Core Data Migration

Postby scotteg » Fri Mar 01, 2013 2:28 pm

@johnheb Thanks! I haven't done anything with iCloud in a while. What I have been meaning to do though is check out StackMob's service, which is integrated with Core Data. What sort of issues are you having with using Core Data and iCloud after doing a migration? Also, have you filed a radar with Apple?
User avatar
scotteg
iOS Tutorial Team Member
 
Posts: 14
Joined: Sun May 01, 2011 11:15 pm
Location: Greater St. Louis area
Has thanked: 3 times
Been thanked: 1 time


Return to Official Tutorials

Who is online

Users browsing this forum: No registered users and 3 guests