How to print Core Data debug values?

后端 未结 2 484
迷失自我
迷失自我 2020-12-02 23:36

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 \"

相关标签:
2条回答
  • 2020-12-03 00:11

    If you are using Xcode 8, you will need to also need to add additional argument

    -com.apple.CoreData.Logging.stderr 1
    
    0 讨论(0)
  • 2020-12-03 00:20

    Open "Product -> Scheme -> Edit Scheme..." in Xcode and add to "Arguments Passed on Launch":

    -com.apple.CoreData.SQLDebug 3
    -com.apple.CoreData.Logging.stderr 1 
    

    (The second launch argument is needed for Core Data debugging on iOS 10/macOS 10.12 or later, see com.apple.CoreData.SQLDebug not working for more information.)

    The you'll see 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
    
    0 讨论(0)
提交回复
热议问题