From 599b1a64950cba8543b5c57657fa878524cb0d02 Mon Sep 17 00:00:00 2001 From: momo <928627819@qq.com> Date: Mon, 2 May 2016 19:49:57 +0800 Subject: [PATCH] fix a bug --- SUIMVVMDemo/.DS_Store | Bin 6148 -> 6148 bytes SUIMVVMKit/SUIMVVMKit/NSObject+SMKCoding.m | 26 ++++++++++++++------- SUIMVVMKit/SUIMVVMKit/SMKAction.m | 12 +++++----- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/SUIMVVMDemo/.DS_Store b/SUIMVVMDemo/.DS_Store index 63c5dc5204555e8d1f877c01640e30881ac374c3..822277a87230877a3caf66699f1893c7df6962eb 100644 GIT binary patch delta 34 kcmZoMXffEZfQ`{$@P5@4ehtejS!`asg0080I4G#bS 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 {