             }
             builder += "\(entity.accessibility.sourceName) class \(getWrapperName(entity.name, variable.name)): RealmSwift.Object, Torch.ValueTypeWrapper {"
             if isValueConvertible(variable) {
-                builder.nest("dynamic var value = \(variable.rawType).getDefaultValue().toValue()")
+                builder.nest("@objc dynamic var value = \(variable.rawType).getDefaultValue().toValue()")
             } else {
-                 builder.nest("dynamic var value = \(variable.rawType)()")
+                 builder.nest("@objc dynamic var value = \(variable.rawType)()")
             }
             builder += "}"
         }
         return builder
     }
-    
-    
+
+
     fileprivate func isTorchEntity(_ variable: InstanceVariable) -> Bool {
         return allEntities.contains(variable.rawType)
     }
-    
-    
+
+
     fileprivate func isId(_ variable: InstanceVariable) -> Bool {
         return variable.name == "id"
     }
-    
-    
+
+
     fileprivate func isArrayWithValues(_ variable: InstanceVariable) -> Bool {
         return variable.isArray && !isTorchEntity(variable)
     }
-    
-    
+
+
     fileprivate func isRealmOptional(_ variable: InstanceVariable) -> Bool {
         return variable.isOptional && Generator.RealmOptionalTypes.contains(variable.rawType)
     }
-    
-    
+
+
     fileprivate func isValueConvertible(_ variable: InstanceVariable) -> Bool {
         return !Generator.ValueTypes.contains(variable.rawType) && !isTorchEntity(variable)
     }
-    
-    
+
+
     fileprivate func getManagedObjectName(_ entityName: String) -> String {
         return "Torch_" + entityName
     }
 
-    
+
     fileprivate func getManagedObjectType(_ entityName: String) -> String {
         return entityName + ".ManagedObjectType"
     }
 
-    
+
     fileprivate func getWrapperName(_ entityName: String, _ variableName: String) -> String {
         return getManagedObjectName(entityName) + "_" + variableName
     }
-    
-    
+
+
     fileprivate func getIsNilName(_ variableName: String) -> String {
         return getPrefixedPropertyName(variableName) + "_isNil"
     }
 
-    
+
     fileprivate func getPrefixedPropertyName(_ variableName: String) -> String {
         return "torch_\(variableName)"
     }

        builder += "}"
        return builder
    }
    
    
    fileprivate func generateUpdateManagedObject(_ entity: StructDeclaration, variables: [InstanceVariable]) -> CodeBuilder {
        var builder = CodeBuilder()
        builder += "\(entity.accessibility.sourceName) mutating func torch_update(managedObject object: \(getManagedObjectName(entity.name)), database: Torch.Database) {"

//

public struct Generator {

    fileprivate static let ValueTypes = ["Bool", "Int8", "Int16", "Int32", "Int64", "Int", "Double", "Float", "String", "Date", "NSDate", "NSData"]
    fileprivate static let RealmOptionalTypes = ["Bool", "Int8", "Int16", "Int32", "Int64", "Int", "Double", "Float"]

    fileprivate let allEntities: [String]

    public init(allEntities: [StructDeclaration]) {
        self.allEntities = allEntities.map { $0.name }
    }


    public func generate(_ entities: [StructDeclaration]) -> String {
        var builder = CodeBuilder()
        var first = true
