-
-
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 | |
| { | |
| #ifdef XEncodeBools | |
| #define X(ivar) [coder encodeBool:ivar forKey:@"" #ivar]; | |
| XEncodeBools | |
| #undef X | |
| #ifndef XSynthesizeCodersFoundSources | |
| #define XSynthesizeCodersFoundSources | |
| #endif | |
| #endif | |
| #ifdef XEncodeDoubles | |
| #define X(ivar) [coder encodeDouble:ivar forKey:@"" #ivar]; | |
| XEncodeDoubles | |
| #undef X | |
| #ifndef XSynthesizeCodersFoundSources | |
| #define XSynthesizeCodersFoundSources | |
| #endif | |
| #endif | |
| #ifdef XEncodeIntegers | |
| #define X(ivar) [coder encodeInteger:ivar forKey:@"" #ivar]; | |
| XEncodeIntegers | |
| #undef X | |
| #ifndef XSynthesizeCodersFoundSources | |
| #define XSynthesizeCodersFoundSources | |
| #endif | |
| #endif | |
| #ifdef XEncodeObjects | |
| #define X(ivar) [coder encodeObject:ivar forKey:@"" #ivar]; | |
| XEncodeObjects | |
| #undef X | |
| #ifndef XSynthesizeCodersFoundSources | |
| #define XSynthesizeCodersFoundSources | |
| #endif | |
| #endif | |
| } | |
| -(id) initWithCoder: (NSCoder*) decoder | |
| { | |
| #ifdef XEncodeBools | |
| #define X(ivar) [decoder decodeBoolForKey:@"" #ivar]; | |
| XEncodeBools | |
| #undef X | |
| #endif | |
| #ifdef XEncodeIntegers | |
| #define X(ivar) [decoder decodeIntegerForKey:@"" #ivar]; | |
| XEncodeIntegers | |
| #undef X | |
| #endif | |
| #ifdef XEncodeDoubles | |
| #define X(ivar) [decoder decodeDoubleForKey:@"" #ivar]; | |
| XEncodeDoubles | |
| #undef X | |
| #endif | |
| #ifdef XEncodeObjects | |
| #define X(ivar) [decoder decodeObjectForKey:@"" #ivar]; | |
| XEncodeObjects | |
| #undef X | |
| #endif | |
| return self; | |
| } | |
| #ifndef XSynthesizeCodersFoundSources | |
| #warning XSynthesizeCoders found none of XEncodeBools, XEncodeIntegers, XEncodeDoubles or XEncodeObjects | |
| #endif |
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