diff --git a/SUIMVVMDemo/.DS_Store b/SUIMVVMDemo/.DS_Store index 63c5dc5..822277a 100644 Binary files a/SUIMVVMDemo/.DS_Store and b/SUIMVVMDemo/.DS_Store differ diff --git a/SUIMVVMKit/SUIMVVMKit/NSObject+SMKCoding.m b/SUIMVVMKit/SUIMVVMKit/NSObject+SMKCoding.m index acbc2cf..5c4fa75 100644 --- a/SUIMVVMKit/SUIMVVMKit/NSObject+SMKCoding.m +++ b/SUIMVVMKit/SUIMVVMKit/NSObject+SMKCoding.m @@ -1,6 +1,6 @@ // // NSObject+SMKCoding.m -// SMKMVVM +// TestSql // // Created by yuantao on 16/4/29. // Copyright © 2016年 momo. All rights reserved. @@ -18,7 +18,7 @@ + (BOOL)supportsSecureCoding { #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wobjc-designated-initializers" - (instancetype)initWithCoder:(NSCoder *)aDecoder { - [self setWithCoder:aDecoder]; + [self setWithCoder:aDecoder]; return self; } #pragma clang diagnostic pop @@ -38,14 +38,22 @@ - (void)setWithCoder:(NSCoder *)aDecoder { } - (NSDictionary *)getPropertiesDict { - + Class class = [self class]; unsigned int propertyCount; __autoreleasing NSMutableDictionary *propertiesDict = [NSMutableDictionary dictionary]; objc_property_t *properties = class_copyPropertyList(class, &propertyCount); - - NSArray *allowedCodingPropertyNames = [class smk_allowedCodingPropertyNames]; - NSArray *ignoredCodingPropertyNames = [class smk_ignoredCodingPropertyNames]; + + NSArray *allowedCodingPropertyNames = nil; + if ([self respondsToSelector:@selector(smk_allowedCodingPropertyNames)]) { + allowedCodingPropertyNames = [class smk_allowedCodingPropertyNames]; + } + + NSArray *ignoredCodingPropertyNames = nil; + if ([self respondsToSelector:@selector(smk_ignoredCodingPropertyNames)]) { + ignoredCodingPropertyNames = [class smk_ignoredCodingPropertyNames]; + } + void(^setValueBlock)(NSString *key, NSMutableDictionary *propertiesDict) = ^(NSString *key, NSMutableDictionary *propertiesDict) { if (![ignoredCodingPropertyNames containsObject:key]) { @@ -75,7 +83,7 @@ - (NSDictionary *)getPropertiesDict { const char *propertyName = property_getName(property); __autoreleasing NSString *key = @(propertyName); setValueBlock(key, propertiesDict); - + } free(properties); @@ -105,9 +113,9 @@ - (BOOL)smk_writeToFile:(NSString *)path atomically:(BOOL)useAuxiliaryFile { } + (instancetype)smk_objectWithFile:(NSString *)path { - + NSData *data = [NSData dataWithContentsOfFile:path]; - + id object = nil; if (data) { NSPropertyListFormat format; diff --git a/SUIMVVMKit/SUIMVVMKit/SMKAction.m b/SUIMVVMKit/SUIMVVMKit/SMKAction.m index c8d9c7e..9baf7d0 100644 --- a/SUIMVVMKit/SUIMVVMKit/SMKAction.m +++ b/SUIMVVMKit/SUIMVVMKit/SMKAction.m @@ -31,29 +31,29 @@ @interface SMKAction () @implementation SMKAction -static id _instace; +static id _instance; + (id)allocWithZone:(struct _NSZone *)zone { static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ - _instace = [super allocWithZone:zone]; + _instance = [super allocWithZone:zone]; }); - return _instace; + return _instance; } + (instancetype)sharedAction { static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ - _instace = [[self alloc] init]; + _instance = [[self alloc] init]; }); - return _instace; + return _instance; } - (id)copyWithZone:(NSZone *)zone { - return _instace; + return _instance; } - (AFHTTPSessionManager *)sessionManager {