NSObject+SMKCoding.h文件
#import <Foundation/Foundation.h>
/**
* SMKCodingProtocol个性化设置archiver协议
*/
@protocol SMKCodingProtocol <NSObject>
@optional
/**
* 这个数组中的属性名才会进行归档
*/
+ (NSArray *)smk_allowedCodingPropertyNames;
/**
* 这个数组中的属性名将会被忽略:不进行归档
*/
+ (NSArray *)smk_ignoredCodingPropertyNames;
@end
@interface NSObject (SMKCoding) <SMKCodingProtocol>
/**
* archiver
*/
- (BOOL)smk_writeToFile:(NSString *)path atomically:(BOOL)useAuxiliaryFile;
/**
* unarchiver
*/
+ (instancetype)smk_objectWithFile:(NSString *)path;
@end
NSObject+SMKCoding.m文件
#import "NSObject+SMKCoding.h"
#import <objc/runtime.h>
@implementation NSObject (SMKCoding)
+ (BOOL)supportsSecureCoding {
return YES;
}
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wobjc-designated-initializers"<