vendor/Pods/NanoStore/Classes/Public/NSFNanoObject.m in nano-store-0.6.1 vs vendor/Pods/NanoStore/Classes/Public/NSFNanoObject.m in nano-store-0.6.2

- old
+ new

@@ -28,22 +28,17 @@ #import "NSFNanoObject_Private.h" #import "NSFNanoGlobals.h" #import "NSFNanoGlobals_Private.h" #import "NSFOrderedDictionary.h" -@interface NSFNanoObject () -/** \cond */ -@property (nonatomic, weak, readwrite) NSFNanoStore *store; -@property (nonatomic, copy, readwrite) NSString *key; -/** \endcond */ -@end - @implementation NSFNanoObject { - NSMutableDictionary *_info; + NSMutableDictionary *info; } +@synthesize info, key, originalClassString; + + (NSFNanoObject *)nanoObject { return [[self alloc]initNanoObjectFromDictionaryRepresentation:nil forKey:nil store:nil]; } @@ -72,17 +67,17 @@ // We allow a nil dictionary because: 1) it's interpreted as empty and 2) reduces memory consumption on the caller if no data is being passed. if ((self = [self init])) { // If we have supplied a key, honor it and overwrite the original one if (nil != aKey) { - _key = aKey; + key = [aKey copy]; } // Keep the dictionary if needed if (nil != aDictionary) { - _info = [NSMutableDictionary new]; - [_info addEntriesFromDictionary:aDictionary]; + info = [NSMutableDictionary new]; + [info addEntriesFromDictionary:aDictionary]; } _store = aStore; } @@ -102,14 +97,14 @@ - (NSDictionary *)dictionaryDescription { NSFOrderedDictionary *values = [NSFOrderedDictionary new]; values[@"NanoObject address"] = [NSString stringWithFormat:@"%p", self]; - values[@"Original class"] = (nil != _originalClassString) ? _originalClassString : NSStringFromClass ([self class]); - values[@"Key"] = _key; - values[@"Property count"] = @([_info count]); - values[@"Contents"] = _info; + values[@"Original class"] = (nil != originalClassString) ? originalClassString : NSStringFromClass ([self class]); + values[@"Key"] = key; + values[@"Property count"] = @([info count]); + values[@"Contents"] = info; return values; } - (NSString *)JSONDescription @@ -123,63 +118,63 @@ } - (void)addEntriesFromDictionary:(NSDictionary *)otherDictionary { // Allocate the dictionary if needed - if (nil == _info) { - _info = [NSMutableDictionary new]; + if (nil == info) { + info = [NSMutableDictionary new]; } - [_info addEntriesFromDictionary:otherDictionary]; + [info addEntriesFromDictionary:otherDictionary]; } - (void)setObject:(id)anObject forKey:(NSString *)aKey { // Allocate the dictionary if needed - if (nil == _info) { - _info = [NSMutableDictionary new]; + if (nil == info) { + info = [NSMutableDictionary new]; } - [_info setObject:anObject forKey:aKey]; + [info setObject:anObject forKey:aKey]; } - (id)objectForKey:(NSString *)aKey { - return [_info objectForKey:aKey]; + return [info objectForKey:aKey]; } - (void)removeObjectForKey:(NSString *)aKey { - [_info removeObjectForKey:aKey]; + [info removeObjectForKey:aKey]; } - (void)removeAllObjects { - [_info removeAllObjects]; + [info removeAllObjects]; } - (void)removeObjectsForKeys:(NSArray *)keyArray { - [_info removeObjectsForKeys:keyArray]; + [info removeObjectsForKeys:keyArray]; } - (BOOL)isEqualToNanoObject:(NSFNanoObject *)otherNanoObject { if (self == otherNanoObject) { return YES; } BOOL success = YES; - if (_originalClassString != otherNanoObject.originalClassString) { - if (NO == [_originalClassString isEqualToString:otherNanoObject.originalClassString]) { + if (originalClassString != otherNanoObject.originalClassString) { + if (NO == [originalClassString isEqualToString:otherNanoObject.originalClassString]) { success = NO; } } if (YES == success) { - success = [_info isEqualToDictionary:otherNanoObject.info]; + success = [info isEqualToDictionary:otherNanoObject.info]; } return success; } @@ -198,13 +193,13 @@ /** \cond */ - (id)init { if ((self = [super init])) { - _key = [NSFNanoEngine stringWithUUID]; - _info = nil; - _originalClassString = nil; + key = [[NSFNanoEngine stringWithUUID]copy]; + info = nil; + originalClassString = nil; _store = nil; } return self; } @@ -228,20 +223,20 @@ return self.key; } - (id)rootObject { - return _info; + return info; } #pragma mark - #pragma mark Private Methods #pragma mark - - (void)_setOriginalClassString:(NSString *)theClassString { - if (_originalClassString != theClassString) { - _originalClassString = theClassString; + if (originalClassString != theClassString) { + originalClassString = theClassString; } } + (NSString *)_NSObjectToJSONString:(id)object error:(NSError **)error {