Felipe Sabino Felipe Sabino - 2 months ago 24
iOS Question

How to print Core Data debug values?

How can I print the values being sent to the sqlite database while using Core Data SQL Debug?

Using the "-com.apple.CoreData.SQLDebug 1" in my "Arguments Passed on Launch" debug options prints the SQL structure just fine

(you can check see how to use this here: XCode4 and Core Data: How to enable SQL Debugging)

But the problem is that the NSLog printed is something like

UPDATE ZTABLE SET ZCOLUMN = ? WHERE ZID = ?
and it does not help at all if you are trying to see what is the full SQL statement and/or data being sent to the database.

Answer

With the launch argument

-com.apple.CoreData.SQLDebug 3

you see also all the values that the SQL statements are bound to. Example output:

test56[1588:c07] CoreData: sql: BEGIN EXCLUSIVE
test56[1588:c07] CoreData: sql: INSERT INTO ZEVENT(Z_PK, Z_ENT, Z_OPT, ZTIMESTAMP) VALUES(?, ?, ?, ?)
test56[1588:c07] CoreData: details: SQLite bind[0] = (int64)13
test56[1588:c07] CoreData: details: SQLite bind[1] = (int64)1
test56[1588:c07] CoreData: details: SQLite bind[2] = (int64)1
test56[1588:c07] CoreData: details: SQLite bind[3] = "368650709.435904"
test56[1588:c07] CoreData: sql: COMMIT