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

- old
+ new

@@ -28,17 +28,22 @@ #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]; } @@ -67,17 +72,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 copy]; + _key = aKey; } // Keep the dictionary if needed if (nil != aDictionary) { - info = [NSMutableDictionary new]; - [info addEntriesFromDictionary:aDictionary]; + _info = [NSMutableDictionary new]; + [_info addEntriesFromDictionary:aDictionary]; } _store = aStore; } @@ -97,14 +102,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 @@ -118,63 +123,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; } @@ -193,13 +198,13 @@ /** \cond */ - (id)init { if ((self = [super init])) { - key = [[NSFNanoEngine stringWithUUID]copy]; - info = nil; - originalClassString = nil; + _key = [NSFNanoEngine stringWithUUID]; + _info = nil; + _originalClassString = nil; _store = nil; } return self; } @@ -223,20 +228,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 {