Can I identify the sqlite database used from an NSManagedObject

50 views Asked by At

I'm working on a complex project that involves several different databases being accessed in the program.

If I'm at a breakpoint in XCode and have a reference to an NSManagedObject, is it possible to backtrack through the hierarchy of objects and identify which sqlite database this NSManagedObject came from?

Thanks

1

There are 1 answers

0
Logicsaurus Rex On

Found it... the database can be identified from the LLDB command line like this...

po [[[theNSManagedObject managedObjectContext] persistentStoreCoordinator] persistentStores]

And in many/most/all cases, the persistentStores returns only a single database, and that database will be the one the record came from.