Version 1.0 of an application has a data model, which is saved/loaded using the NSKeyed(Un)Archiver classes, as all model classes adhere to the NSCoding protocol. Say the following hierarchy exists:
-> Houses (NSMutableArray)
-> -> House (Custom Object)
-> -> -> Color (3 ints, RGB)
-> -> -> Number of Residents (int)
Say that there are legacy files stored in such a manner, but need to be loaded into version 2.0 of the application for backwards compatibility, using the following newer data model:
-> Neighborhood (Maintains NSMutableArray, among other properties)
-> -> TownHouse
-> -> -> Color (3 ints, RGB)
-> -> -> Occupants (NSMutableArray)
-> -> (Other types of houses)
Obviously, some data will be missing and will need to be filled in. Eg. a basic "Occupant" object will need to be created for each of the "number of residents" that existed before. What I'm looking for is a way to programmatically load in the previous data model, especially if I only have a list of the classes/hierarchy, and not the .m/.h files themselves.
So what I want to do is (assuming I have a file Houses.data, which was serialized using the Houses array):
NSFile *legacyFile;
Neighborhood *hood = [Neighborhood neighborhoodFromLegacyFile:legacyFile];
Any ideas?