we are facing a new exception after upgrading to iOS couchbase lite 1.3.1,especially after deleting the database and creating again.After long time of analysis, understood that issue is due to CBL_Shared property of CBLManager retains some old reference. More details below,
1.Before deleting the database,created four different views using different instances of databases.
CBLManager *cblManager = [[CBLManager sharedInstance]copy]; CBLDatabase *couchDB = [cblManager databaseNamed:databaseName error:&error];
2. After deleting the database,checked the CBL_Shared property of the database’s manager, it was nil.
3. Created new database.Check the shared property of the newly created database’s manager(before creating any new views), it showed the same four views as a value, for key “mapversiontable”.
Also understood from the source code that, when a new view is created, it expects the viewID value as “-1”, since it holds the old reference, returns the value which is greater than “0” and the app is crashing because of that
Deleting the database should wipe out all the caches and old data right? How it is happening then?
Sorry Jens. Let me explain the above steps with code snippets and screenshots.
1.Created a database and created some views using that database as below,
Though i have just created the database, already created views are shown in the newly created database CBL_Shared property.We tried clearing cache or any temp documents (after database deletion) if any exists, but could not find anything. Pls help us out on this issue.
I think that’s your problem. Closing the manager implicitly closes all its databases. Deleting a database after closing it is technically illegal; it’s probably a no-op.
Delete the database first, then close the manager.
Why do you make a copy of the shared CBLManager just for that one call?
You should have one CBLManager instance, hold that in a long-lived variable, and use it for everything on that thread. (If you use multiple threads, do the same with each thread.)
PS: To quote blocks of code, put a line of three back-quotes before and another after the code.