         
     }
     
+    /**
     func registerObject() -> UID {
         var pos = self.register()
         return self.calculateID(pos)
+    }
+    */
+    
+    
+    func registerObject(aObj: O) -> UID? {
+        
+        var result: UID? = nil
+        
+        if !aObj.uid {
+            // only NEW object have a nil uid
+            
+            var pos  = self.register()
+            result = self.calculateID(pos)
+            aObj.uid = result
+            
+            self.cache.setObject(aObj, forKey: result)
+         
+        }
+        
+        return result;
     }
     
     func createObject() -> O {
         
         var result = O()
-        
+
         self.addObject(result)
         
         return result
     }
     
-
     func addObject(aObj: O) -> UID {
         
         var pos = self.register()

        aObj.uid = self.calculateID(pos)
        aObj.dirty = false
        
        return uid
    }
    
    
    func readObject(aID: UID) -> O? {
        
        var data = self[aID]
        
        if data {
            var result = O()
            result.uid = aID
            
            return result
            
        }
        
        return nil;
    }

    func updateObject(aObj: O) {

    func deleteObject(aObj: O) {
        
        if aObj.uid {
            self.cache.removeObjectForKey(aObj.uid!)
            self.deleteData(aObj.uid!)
            aObj.uid = nil;
        }
