Saturday 31 October 2020

No exact matches in call to intializer

I have recently shifted to Xcode 12 and start getting error which is not there in the Xcode 11. The Error is related to an Extension which says No exact matches in call to intializer Below is the code -

public typealias UpdateBlock<T> = (_ object: T?) -> Void

protocol ModelMappeable {
    func map(_ values: JSON, realm: Realm?)
}

extension ModelMappeable where Self: BaseModel {
    
    static func getOrCreate(realm: Realm, values: JSON?, updates: UpdateBlock<Self>?) -> Self {
        var object: Self!
        
        if let primaryKey = values?["_id"].string {
            if let newObject = realm.object(ofType: Self.self, forPrimaryKey: primaryKey as AnyObject) {
                object = newObject
            }
        }

        if object == nil {
            object = self()
        }

        if let values = values {
            object.map(values, realm: realm)
        }

        updates?(object)
        return object
    }

}

enter image description here

enter image description here



from No exact matches in call to intializer

No comments:

Post a Comment