I have an iOS application with data that is saved using NSCoding and, more precisely, NSKeyedArchiver. This app is already available on the App Store.
I am working on version 2 of the application and the data model needs to change. Therefore, I need to handle the migration of the data model. I want it covered by unit tests.
In my tests, I want to dynamically generate stored data with the old data model, start the migration, and see if everything went well.
Currently, archiving an object is as follows:
MyDataModelObject *object = .... NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:data]; [archiver encodeObject:object forKey:key]; [archiver finishEncoding];
The problem is that MyDataModelObject can be reinstalled or even removed in version 2 of the application. Therefore, I cannot use this class in my tests to create an "old version archive".
Is there any way to simulate what is done in the encodeWithCoder: class method without using this class?
I would like to get the following
- testMigrationFrom_v1_to_v2 {
source share