NSKeyedArchiver/NSKeyedUnarchiver compatibility on different iOS versions

In an iOS app, we are using serialization of complex objects through NSKeyedArchiver/NSKeyedUnarchiver to store info and data.

So the app will include such a serialized object in the app bundle, and this file will be created under one specific iOS version (let's say iOS 5.0)

As the app will be running on different iOS versions (> 5.0) and even in future versions to come, we want to be sure that the original serialized object included in the app bundle will be perfectly readable on every other iOS (6.1, 7.0, ...)

Assuming that the complex object to serialize is composed of objects whose classes are included in the SDKs of all these iOS versions (for sake of simplicity let's assume no deprecation will occur in the future on these classes), can we be completely sure that it will always be compatible with all the iOSs?


Generally, yes.

To be absolutely 100% sure you would need to use all custom objects and then you have full control over the archive / unarchive process. But, so long as all the classes are appropriately using the encode and decode methods of the keyed archiver then everything will be future compatible.

If Apple ever did decide to break this for some reason, you best option is to catch the resulting exception and inform the user that they will need to obtain an upgrade to the app.

Your alternate approach is to store the initial deployment of data in a different format (like JSON, maybe compressed) then at app startup if you have an existing version, use it, if not, read in the initial deployment data.

Need Your Help

Flash AS3 load and replace movie

actionscript-3 loading

I have a loader mc...an animation that loops - when you click a button I want a new movie to load on top and replace the loader mc

How to discover if a software was installed on user machine via web

asp.net winforms activex user-agent agent

Here in my company we have a lot of .NET softwares both Windows Forms and Web Forms.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.