From 5ff282c9807a980f372bdec9c0738ac78f3253a8 Mon Sep 17 00:00:00 2001 From: Dima Zen Date: Fri, 19 May 2017 21:03:56 +0300 Subject: [PATCH] GH-96 Add uniquing identifier for Mapping --- FastEasyMapping/Source/Mapping/FEMMapping.h | 3 +++ FastEasyMapping/Source/Mapping/FEMMapping.m | 2 ++ 2 files changed, 5 insertions(+) diff --git a/FastEasyMapping/Source/Mapping/FEMMapping.h b/FastEasyMapping/Source/Mapping/FEMMapping.h index 202ad47..cd8d544 100644 --- a/FastEasyMapping/Source/Mapping/FEMMapping.h +++ b/FastEasyMapping/Source/Mapping/FEMMapping.h @@ -87,6 +87,9 @@ NS_ASSUME_NONNULL_BEGIN /// CoreData entity name used during CoreData-targeted mapping. It can be nil for NSObject-targeted mappings. @property (nonatomic, copy, nullable) NSString *entityName; +/// Opaque unique value that is used internally to combine different in-memory instances that describes same Class / Entity. +@property (nonatomic, strong, readonly) NSNumber *uniquingIdentifier; + /** @brief path to the Object's representation in the JSON. Same as `keyPath` property of the `FEMProperty` protocol. diff --git a/FastEasyMapping/Source/Mapping/FEMMapping.m b/FastEasyMapping/Source/Mapping/FEMMapping.m index a7274ce..ce995d8 100644 --- a/FastEasyMapping/Source/Mapping/FEMMapping.m +++ b/FastEasyMapping/Source/Mapping/FEMMapping.m @@ -20,6 +20,7 @@ - (instancetype)initWithObjectClass:(Class)objectClass { _relationshipMap = [NSMutableDictionary new]; _objectClass = objectClass; + _uniquingIdentifier = @((NSUInteger)objectClass); } return self; @@ -41,6 +42,7 @@ - (instancetype)initWithEntityName:(NSString *)entityName { _relationshipMap = [NSMutableDictionary new]; _entityName = [entityName copy]; + _uniquingIdentifier = @(entityName.hash); } return self;