如何打印核心数据调试值? [英] How to print Core Data debug values?

查看:109
本文介绍了如何打印核心数据调试值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在使用Core Data SQL Debug时打印发送到sqlite数据库的值?

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

使用 -com.apple.CoreData。在您的启动时传递的参数中的SQLDebug 1 打印出的SQL结构很好

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

如何在这里使用: XCode4和Core Data:如何启用SQL Debugging

但问题是NSLog打印的是类似 UPDATE ZTABLE SET ZCOLUMN =? WHERE ZID =?,如果你试图看看是什么是完整的SQL语句和/或发送到数据库的数据,它根本不起作用。

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.

推荐答案

在Xcode中打开Product - > Scheme - > Edit Scheme ...,并将
添加到Arguments Passed on Launch:

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 

(第二个启动参数是
上的Core Data调试所需的iOS 10 / macOS 10.12或更高版本,请参阅 com.apple.CoreData.SQLDebug无法正常工作了解更多信息。)

(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.)

您将看到SQL语句绑定到的所有值。
示例输出:

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

这篇关于如何打印核心数据调试值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆