init(document: CBLDocument!) {
super.init(document)
}
var x: CBLDocument?
#import <CouchbaseLite/CouchbaseLite.h> class func newInstance(team: Team!) -> Game
// Use the designated initializer
let game = Game(newDocumentInDatabase: team.database)
// Do whatever inititalization you want to do here. In my case I needed to do some initialization based on the team argument
// If you want to return a saved instance, you can save it first
var error: NSError?
game.save(&error)
if (error != nil) {
DDLog.logError("Error creating game for \(team): \(error!)")
return nil
} else {
DDLog.logInfo("Created game: \(game)"
}
return game
}
Can You share the method?
On Tuesday, October 14, 2014 3:38:42 PM UTC+2, Julian Paas wrote:
No I never figured it out. I worked around it by creating a factory method on my class for creating new instances that initializes the object the way I wanted to. Kinda lame, but it works.
On Tuesday, October 14, 2014 9:28:52 AM UTC-4, Karel-Jan Van Haute wrote:It lo
typealias CBLDoc = CBLDocument
class Profile: CBLModel {
override init!(document: CBLDoc) {
super.init(document: document)
}
}