gpt4 book ai didi

objective-c - 如何在 xcode 中显示 objective-c 描述

转载 作者:太空狗 更新时间:2023-10-30 03:38:30 24 4
gpt4 key购买 nike

我对 Xcode 中的“显示摘要”功能有疑问 this guys正在谈论。

目前,我在我的 Objective-C 类中实现了 descriptiondebugDescription,我只需键入 po myObject 即可快速查看的内容,这节省了我的时间。

但是,我想知道是否有办法让它显示在“显示摘要”中。有点像当有一个 NSString 时,它只是在内容 Pane 中向您显示字符串,而无需您做进一步的工作。

我也为我自己的元素这样做吗?这会节省我很多时间:)

谢谢各位。

编辑感谢 Martin R 的评论,我设法得到了我想要的东西:) Link

最佳答案

基本上您可以使用像下面这样的 python 脚本来获取与任何对象关联的任何自定义摘要

# filename : customSummaries.py
import lldb

def someClass_summary(valueObject, dictionary):
# get properties from object
ivar1 = valueObject.GetChildMemberWithName('_ivar')
ivar2 = valueObject.GetChildMemberWithName('_ivar2')

# convert values into python intrinsics
error = lldb.SBError()
var1 = ivar1.GetData().GetFloat(error, 0)
var2 = ivar2.GetData().GetDouble(error, 0)

# string generation we're gonna use for the summaries
valueRepr1 = str(var1)
valueRepr2 = str(var2)

return 'value1= ' + valueRepr1 + ', value2= ' + valueRepr2

# this function gets called by the lldb as this script is imported
def __lldb_init_module(debugger, dict):

# this adds automatically your summaries as the script gets imported
debugger.HandleCommand('type summary add Class -F customSummaries.someClass_summary')

要在 lldb 运行时加载自定义摘要,您应该通过运行 command script import/path/to/customSummaries.py 导入上面的脚本,仅此而已。

关于objective-c - 如何在 xcode 中显示 objective-c 描述,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16856353/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com