views:

26

answers:

1

Hello

I am developing for iPhone/iPad.

I already know how to read/write text files from/to the documents folder and now I need to write structured files, e.g. let's say I have a class in my application that is called A which contains an integer i and integer j and an instance of another class B, let's call it b, now I want to write A to a file in a way that I can read it next time to another object from type A without the need to read a text file and parse its contents (to avoid time cost).

so anyone to help me?

PS: if you used Pascal before, what I need is exactly something like its binary files.

+2  A: 

You can do archive and unarchive. Your class need to conform to NSCoding protocol

MapView *myMapView;   // Assume this exists

NSString *archivePath = [NSTemporaryDirectory() stringByAppendingPathComponent:@"Map.archive"];

result = [NSKeyedArchiver archiveRootObject:myMapView 
                        toFile:archivePath];

Archive and Unarchive. NSCoding protocol

vodkhang