Skip to content

Commit

Permalink
fix a bug
Browse files Browse the repository at this point in the history
  • Loading branch information
lovemo committed May 2, 2016
1 parent cf6b18c commit 599b1a6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 15 deletions.
Binary file modified SUIMVVMDemo/.DS_Store
Binary file not shown.
26 changes: 17 additions & 9 deletions SUIMVVMKit/SUIMVVMKit/NSObject+SMKCoding.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// NSObject+SMKCoding.m
// SMKMVVM
// TestSql
//
// Created by yuantao on 16/4/29.
// Copyright © 2016年 momo. All rights reserved.
Expand All @@ -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
Expand All @@ -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]) {
Expand Down Expand Up @@ -75,7 +83,7 @@ - (NSDictionary *)getPropertiesDict {
const char *propertyName = property_getName(property);
__autoreleasing NSString *key = @(propertyName);
setValueBlock(key, propertiesDict);

}

free(properties);
Expand Down Expand Up @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions SUIMVVMKit/SUIMVVMKit/SMKAction.m
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 599b1a6

Please sign in to comment.