Strange value is returned when "autoEncodeWithCoder"-method deals with NSInteger type
Hi, greenisus. I very like your extension. But recently found a strange behavior. I tried to perform encoding operation with my class, where one of the field is NSInteger property: @property (nonatomic, assign) NSInteger userID;
I have noticed after encoding operation I got a wrong value in userID field. It contained 0 (in my case). I decided to deep into and found that actually I pass a correct number:12. Than - (void)autoEncodeWithCoder:(NSCoder *)coder is called. This method gets Class properties and calls - (NSMutableDictionary *)propertiesForClass:(Class)klass { Here I saw, that my NSInteger extracted via NSString *pattrs = [NSString stringWithCString:property_getAttributes(property) encoding:NSUTF8StringEncoding];
and pattrs contains "Tq,N,V_userID" I went to official documentation:https://developer.apple.com/library/mac/documentation/cocoa/conceptual/objcruntimeguide/articles/ocrtpropertyintrospection.html
And did not find specificator 'q'. Maybe apple has changed smith. But in your code you don't handle this 'q' case in your switch-case block in both methods:
- (void)autoDecode:(NSCoder *)coder
- (void)autoEncodeWithCoder:(NSCoder *)coder
you have case 'Q': // unsigned long long but this 'q' do the same as case 'i': // int
when I added these cases, NSInteger encoding/decoding began work properly.