I have an iOS/swift project with two views that both use CBLUITableSource 
to represent two different lists of CBLModel objects, games and players. 
Each type of CBLModel object holds a reference to another POSO which is 
lazily calculated because its expensive to do so. Its the stats for the 
game or the player. Both of my view controllers implement 
couchTableSource(source: 
CBLUITableSource!, cellForRowAtIndexPath indexPath: NSIndexPath) and in 
both cases they call CBLModel(forDocument: row.document) to get an instance 
of the model object.

On the game list, I get the behaviour I want which is that each game 
instance is instantiated only once and I only ever have to calculate the 
stats once.

However on the players list, the modelObjects seem to get garbage collected 
because I frequently get new instances of player objects and have to 
recalculate the stats. The only obvious difference between the two lists is 
that on the game list I do:

    let game = Game(forDocument: row.document)

and on the players list I do:

    let player = CBLModel(forDocument: row.document) as Player

because there are different types of players and I want the CBLModelFactory 
to figure out which one it is.

Has anyone seen this, or have any idea why this is happening?

-- 
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/175be5ab-38ca-4b8d-a7e3-425e5a73e1a9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to