I was tempted to use a plist to save and load data, but I want the data to be as disk-space efficient as possible, so I will be doing a binary saving and loading of the data of the elements that will be dropped in a level while using the in-game editor.
NSMutableData/CFMutableDataRef did the trick for saving the data, by using CFDataAppendBytes(). Then I created the file using NSFileManager and simply dumped the contents into the created file
I used NSData for loading the data. I kept track of the offset and passed the pointer of the offset to the objects to load themselves up, and modified that offset which is being passed as a pointer. For loading I simply used getBytes:range, e.g. [data getBytes:&type range:NSMakeRange((*offset)++, 1)];
No comments:
Post a Comment