문제

In my app, for every game saved on a device I'm storing the game object in an NSDictionary along with some other meta data that gets archived with NSKeyedArchiver.

I'm trying to avoid having to alloc/init the game object every time I want peak at the game data as the game objects can become fairly large. So I use the meta data to get basic info about it in order to build menus, etc.

I have 2 questions. Is every object in the NSDictionary allocated when it's unarchived? If so, is archiving the game object as NSData and then archiving it again inside the NSDictionary more efficient? Essentially an archive in an archive.

도움이 되었습니까?

해결책

Yes, the whole dictionary is unarchived at the same time. You might want to create some wrapper and/or save each game state as 2 files (one for the metadata and one for the full state), possibly with each game in its own folder.

Putting archived data into a dictionary and then archiving the dictionary doesn't solve your initial problem and will take longer. The solution is to separate the 2 parts of data so they can be unarchived separately.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top