novastone-media / MQTT-Client-Framework

iOS, macOS, tvOS native ObjectiveC MQTT Client Framework
Other
1.84k stars 465 forks source link

[FIX] Setting PERSISTENCE = YES #444 #445

Closed ckrey closed 6 years ago

ckrey commented 6 years ago

The problem can be solved by lazy initialization of the NSPersistentStoreCoordinator

jcavar commented 6 years ago

Interesting, thanks @ckrey. Would it be possible to add some tests around this?

jcavar commented 6 years ago

Also, are maybe some other issues related to this?

ckrey commented 6 years ago

Checks are difficult, because you see the results of persistence / non persistence only when you kill and restart the App in between...

I don't see any other open issue related to this. The CoreData persistence works exactly the same whether it is memory based or backed by SQLLite except is does not survive a kill app.

The persistence worked fine probably until 7 months ago when you solved a lot of concurrency problems by doing this: (this actually disabled the PERSISTENCE = YES setting)

bildschirmfoto 2018-04-06 um 16 30 37

jcavar commented 6 years ago

Gotcha, but we could add test where we initialise MQTTSession set persistence to YES or NO and assert that store type is NSSQLiteStoreType or NSInMemoryStoreType. This test would catch if someone tries to do something like I did in past?

jcavar commented 6 years ago

I've added those tests here: https://github.com/novastone-media/MQTT-Client-Framework/pull/454

so I will merge this.

Thanks @ckrey!