-
-
Save orj/5418430 to your computer and use it in GitHub Desktop.
Revisions
-
orj revised this gist
Apr 19, 2013 . 2 changed files with 5 additions and 5 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,18 +1,18 @@ -(void) encodeWithCoder: (NSCoder*) coder { #define X(type, ivar) [coder encode##type:ivar forKey:@#ivar]; #define BOX(type, ivar) [coder encodeObject:([NSValue valueWith##type:ivar]) forKey:@#ivar]; XEncodeIvars #undef BOX #undef X } -(id) initWithCoder: (NSCoder*) decoder { #define X(type, ivar) ivar = [decoder decode##type##ForKey:@#ivar]; #define BOX(type, ivar) ivar = [[decoder decodeObjectForKey:@#ivar] type##Value]; XEncodeIvars #undef BOX #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 charactersOriginal file line number Diff line number Diff line change @@ -7,7 +7,7 @@ @implementation Foo X(Integer, _anotherInteger) \ X(Object, _anObject) \ X(Object, _anotherObject) \ BOX(MKCoordinate, _location)) #include "XSynthesizeCoders.h" -
aufflick revised this gist
Apr 19, 2013 . 3 changed files with 8 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,14 +1,18 @@ -(void) encodeWithCoder: (NSCoder*) coder { #define X(type, ivar) [coder encode##type:ivar forKey:@#ivar]; #define XX(ivar, encode, decode) do { [coder encodeObject:(encode) forKey:@#ivar]; } while (0); XEncodeIvars #undef XX #undef X } -(id) initWithCoder: (NSCoder*) decoder { #define X(type, ivar) ivar = [decoder decode##type##ForKey:@#ivar]; #define XX(ivar, encode, decode) do { id x = [decoder decodeObjectForKey:@#ivar]; decode; } while (0); XEncodeIvars #undef XX #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 charactersOriginal file line number Diff line number Diff line change @@ -6,5 +6,6 @@ @property NSInteger anotherInteger; @property NSObject * anObject; @property NSObject * anotherObject; @property CLLocationCoordinate2D location; @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 charactersOriginal file line number Diff line number Diff line change @@ -6,7 +6,8 @@ @implementation Foo X(Integer, _anInteger) \ X(Integer, _anotherInteger) \ X(Object, _anObject) \ X(Object, _anotherObject) \ XX(_location, [NSValue valueWithMKCoordinate:_location], [x MKCoordinateValue]) #include "XSynthesizeCoders.h" -
aufflick revised this gist
Apr 19, 2013 . 3 changed files with 14 additions and 75 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,71 +1,14 @@ -(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 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 charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,7 @@ @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 charactersOriginal file line number Diff line number Diff line change @@ -1,16 +1,12 @@ @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" -
aufflick revised this gist
Apr 19, 2013 . 1 changed file with 45 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,27 +1,71 @@ -(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 -
aufflick revised this gist
Apr 19, 2013 . 2 changed files with 0 additions and 0 deletions.There are no files selected for viewing
Binary file not shown.File renamed without changes. -
aufflick created this gist
Apr 19, 2013 .There are no files selected for viewing
Binary file not shown.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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ @implementation Foo #define XEncodeBools \ X(_aBool) \ X(_anotherBool) #define XEncodeIntegers \ X(_anInteger) \ X(_anotherInteger) #define XEncodeObjects \ X(_anObject) \ X(_anotherObject) #include "XSynthesizeCoders.h" @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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ -(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; }