-
-
Save orj/5418338 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
-(void) encodeWithCoder: (NSCoder*) coder | |
{ | |
#define X(type, ivar) [coder encode##type:ivar forKey:@#ivar]; | |
XEncodeIvars | |
#undef X | |
} | |
-(id) initWithCoder: (NSCoder*) decoder | |
{ | |
#define X(type, ivar) ivar = [decoder decode##type##ForKey:@#ivar]; | |
XEncodeIvars | |
#undef X | |
return self; | |
} |
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
@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 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 XEncodeIvars \ | |
X(Bool, _aBool) \ | |
X(Bool, _anotherBool) \ | |
X(Integer, _anInteger) \ | |
X(Integer, _anotherInteger) \ | |
X(Object, _anObject) \ | |
X(Object, _anotherObject) | |
#include "XSynthesizeCoders.h" | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment