Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions NSObject+NSCoding.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ - (void)encodeAutoWithCoder:(NSCoder *)aCoder class:(Class)class
for (int i = 0; i < outCount; i++) {
objc_property_t property = pt[i];
NSString *name = [NSString stringWithUTF8String:property_getName(property)];


if (![self shouldEncodePropertyName:name]) {
continue;
}

SEL selector = NSSelectorFromString(name);
Method mt = class_getInstanceMethod(class, selector);
if (mt != NULL) {
Expand Down Expand Up @@ -108,7 +112,11 @@ - (void)decodeAutoWithAutoCoder:(NSCoder *)aDecoder class:(Class)class
for (int i = 0; i< outCount; i++) {
objc_property_t property = pt[i];
NSString *name = [NSString stringWithUTF8String:property_getName(property)];


if (![self shouldEncodePropertyName:name]) {
continue;
}

SEL selector = NSSelectorFromString([class getSetMethodName:name]);
Method mt = class_getInstanceMethod(class, selector);
if (mt != NULL) {
Expand Down Expand Up @@ -182,6 +190,15 @@ - (void)decodeAutoWithAutoCoder:(NSCoder *)aDecoder

#pragma mark - private

- (BOOL)shouldEncodePropertyName:(NSString *)name {
// Ignore properties indrocuded with iOS 8
if ([@[@"description", @"debugDescription", @"superclass"] containsObject:name]) {
return NO;
}

return YES;
}

+ (NSString *)getMethodReturnType:(Method)mt
{
char dstType[10] = {0};
Expand Down