It looks something like...

  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

}




On Wednesday, October 15, 2014 8:26:45 AM UTC-4, Karel-Jan Van Haute wrote:
>
> 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
>>>
>>> I'm having the same problem. Did you found the reason why you get the 
>>> error?
>>>
>>> On Wednesday, September 24, 2014 3:57:05 AM UTC+2, Julian Paas wrote:
>>>>
>>>> I'm doing this in my bridging header which includes all of the CBL 
>>>> headers. But to be sure I did actually try explicitly adding CBLDocument.h 
>>>> but it didn't help.
>>>> #import <CouchbaseLite/CouchbaseLite.h> 
>>>>
>>>>
>>>>
>>>> On Sunday, September 21, 2014 7:18:45 AM UTC-4, Robbie Bubble wrote:
>>>>>
>>>>> Did you included CBLDocument.h in your bridging header?
>>>>>
>>>>> Am Montag, 15. September 2014 22:37:37 UTC+2 schrieb Julian Paas:
>>>>>>
>>>>>> Does anyone know how to override initWithDocument on CBLModel 
>>>>>> subclasses? I have tried as:
>>>>>>
>>>>>> init(document: CBLDocument!) {
>>>>>>
>>>>>>     super.init(document)
>>>>>>   }  
>>>>>>
>>>>>> But it tells me "use of undeclared type CBLDocument". CBLDocument is 
>>>>>> definitely not unknown I use it in plenty of other swift classes. It 
>>>>>> only 
>>>>>> seems to be in my CBLModel subclass that it is unknown. I get the same 
>>>>>> result if I declare
>>>>>>
>>>>>>
>>>>>>   var x: CBLDocument?
>>>>>>
>>>>>>
>>>>>>

-- 
You received this message because you are subscribed to the Google Groups 
"Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/mobile-couchbase/6f8162d3-ec39-481d-85e1-cbc88f0599fe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to