Created
November 20, 2009 02:51
-
-
Save liyanage/239246 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// LDFLAGS='-framework Foundation' make archivertest | |
#import <Foundation/Foundation.h> | |
typedef enum Foo { | |
Foo1 = 0UL, | |
Foo2 = 1, | |
Foo3 = 2 | |
} FooType; | |
typedef enum Bar { | |
Bar1 = 0x0000UL, | |
Bar2 = 0x0001, | |
Bar3 = 0x0002 | |
} BarType; | |
int main (int argc, const char * argv[]) { | |
FooType a = Foo2; | |
FooType b = Foo1; | |
NSString *testa = @"foo"; | |
NSString *testb = nil; | |
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; | |
NSMutableData *data = [NSMutableData data]; | |
NSArchiver *archiver = [[[NSArchiver alloc] initForWritingWithMutableData:data] autorelease]; | |
// [archiver encodeValueOfObjCType:@encode(BarType) at:&a]; | |
[archiver encodeValueOfObjCType:@encode(FooType) at:&a]; | |
[archiver encodeObject:testa]; | |
NSUnarchiver *unarchiver = [[[NSUnarchiver alloc] initForReadingWithData:data] autorelease]; | |
[unarchiver decodeValueOfObjCType:@encode(unsigned long) at:&b]; | |
// [unarchiver decodeValueOfObjCType:@encode(FooType) at:&b]; | |
testb = [unarchiver decodeObject]; | |
NSLog(@"%d %d %@ %@", a, b, testa, testb); | |
[pool release]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment