-
-
Save orj/5418430 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| -(void) encodeWithCoder: (NSCoder*) coder | |
| { | |
| #define X(ivar) [coder encodeBool:ivar forKey:@"" #ivar]; | |
| XEncodeBools | |
| #undef X | |
| #define X(ivar) [coder encodeInteger:ivar forKey:@"" #ivar]; | |
| XEncodeIntegers | |
| #undef X | |
| #define X(ivar) [coder encodeObject:ivar forKey:@"" #ivar]; | |
| XEncodeObjects | |
| #undef X | |
| } | |
| -(id) initWithCoder: (NSCoder*) decoder | |
| { | |
| #define X(ivar) [decoder decodeBoolForKey:@"" #ivar]; | |
| XEncodeBools | |
| #undef X | |
| #define X(ivar) [decoder decodeIntegerForKey:@"" #ivar]; | |
| XEncodeIntegers | |
| #undef X | |
| #define X(ivar) [decoder decodeObjectForKey:@"" #ivar]; | |
| XEncodeObjects | |
| #undef X | |
| return self; | |
| } |
This file contains hidden or 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
| @interface Foo : NSObject <NSCoder> | |
| @property BOOL aBool; | |
| @property BOOL anotherBool; | |
| @property NSInteger anInteger; | |
| @property NSInteger anotherInteger; | |
| @property NSObject *� anObject; | |
| @property NSObject *� anotherObject; | |
| @end |
This file contains hidden or 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
| @implementation Foo | |
| #define XEncodeBools \ | |
| X(_aBool) \ | |
| X(_anotherBool) | |
| #define XEncodeIntegers \ | |
| X(_anInteger) \ | |
| X(_anotherInteger) | |
| #define XEncodeObjects \ | |
| X(_anObject) \ | |
| X(_anotherObject) | |
| #include "XSynthesizeCoders.h" | |
| @end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment