Custom documentID in CBLModel

#1

I am trying to create a CBLModel subclass with a custom documentID consisting of some attributes of my model.
I am overriding the idForNewDocument method, but how can I use attributes in this function if it it´s called in the factory inits?

`
class MyModel: CBLModel {

class func with(a: String, b: String, n: String) -> MyModel {
    
    let model = MyModel(forNewDocumentIn: CB.shared.database)
    
    return model
}
override func idForNewDocument(in db: CBLDatabase) -> String {
    return "\(self.a)_\(self.b)_\(self.n)"
}

}
`

#2

If you want the model to have a specific doc ID, first get a CBLDocument with that ID from the database, then get a model for that document.

CBLDocument* doc = [db documentWithID: @"whatever-id-you-want"];
MyModel* model = [MyModel modelForDocument: doc];
#3

Thanks Jens, finally I ended doing just that.