Rose Perrone Rose Perrone - 3 months ago 39
iOS Question

View contents of Core Data

I want to be able to see the contents of the

Core Data
contained in my iPhone simulator app from the command line.

I've tried
cd
'ing into
~/Library/Application Support/iPhone Simulator/7.0/Applications
and then using
find . -name MyAppName
to find which of these directories contains my app:

29EB3FF9-4691-474D-8B05-AB168899D528 4C25697B-04D9-4B48-BE5E-D1E9B2E03381 A1DF7916-AE39-4367-BFD2-22A8BAA2AFD2 BDB577A8-0BCF-4E58-896B-D4E704F261D0 CC3CC638-E39D-4AE7-8580-4E8BBD375DC4 D11D7C57-5578-4531-85BB-71AE6DD68B2F


Then I navigate to the
Documents
folder inside this folder, but the only
sqlite
files I see are
CoreDataTabBarTutorial.sqlite CoreDataTabBarTutorial.sqlite-shm CoreDataTabBarTutorial.sqlite-wal
. (EDIT: I had actually named my
persistentStoreCoordinator
's
URL
to
CoreDataTabBarTutorial.sqlite
).

I'm sure that my objects get inserted to
Core Data
, but it appears they don't persist between launches of Interface Builder. I'm trying to debug that.

Answer

Core Data is saved on the device with sqlite.

You can use sqlite3 CoreDataTabBarTutorial.sqlite to view you database from the command line. You will need to use the various sqlite3 commands and SQL to see any values. See Docs

.table will list the tables
select * from ZYOURTABLENAME; (do not forget semi-colon) will display the rows.

There is a Mac app called Base that is a GUI tool for viewing sqlite databases.

Comments