无法在LLDB中传递CGColorRef类型的参数 [英] Can't pass parameter of type CGColorRef in LLDB

查看:134
本文介绍了无法在LLDB中传递CGColorRef类型的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在扩展Facebook的凿子,以便能够从调试器中看到颜色.我希望它适用于UIColorCIColorCGColorRef.两种基于对象的工具都可以正常工作,但是CGColorRef给我带来麻烦.

I'm extending Facebook’s Chisel to be able to visualize a color from the debugger. I want it to work for UIColor, CIColor, and CGColorRef. The two object-based ones are working fine, but the CGColorRef is giving me trouble.

这里是我正在使用的错误,我已经在其中进行了哈希处理从这个问题中找出一堆东西.

Here is the bug I'm working from, where I've already hashed out a bunch of the stuff from this question.

我将问题归结为该测试用例:

I've boiled the issue down to this test case:

如果我有一些功能:

+ (UIColor *)someColor {
    UIColor *uiColor = [UIColor redColor];
    CGColorRef cgColor = uiColor.CGColor;
    UIColor *newUIColor = [UIColor colorWithCGColor:cgColor];
    return newUIColor;
}

然后在return newUIColor;行上设置一个断点,这就是LLDB中发生的情况:

And I set a breakpoint on the return newUIColor; line, this is what happens in LLDB:

(lldb) po cgColor
<CGColor 0x7f992b626710> [<CGColorSpace 0x7f992b70d5b0> (kCGColorSpaceDeviceRGB)] ( 0 0.478431 1 1 )

(lldb) po [UIColor colorWithCGColor:cgColor]
error: cannot initialize a parameter of type 'CGColor *' with an lvalue of type 'CGColorRef' (aka 'CGColor *')
error: 1 errors parsing expression
(lldb) po [UIColor colorWithCGColor:(CGColorRef)cgColor]
error: cannot initialize a parameter of type 'CGColor *' with an rvalue of type 'CGColorRef' (aka 'CGColor *')
error: 1 errors parsing expression
(lldb) po [UIColor colorWithCGColor:(id)cgColor]
error: cannot initialize a parameter of type 'CGColor *' with an rvalue of type 'id'
error: 1 errors parsing expression
(lldb) po [UIColor colorWithCGColor:(CGColor *)cgColor]
error: use of undeclared identifier 'CGColor'
error: expected expression
error: 2 errors parsing expression
(lldb) expr @import CoreGraphics
(lldb) po [UIColor colorWithCGColor:(CGColorRef)cgColor]
error: cannot initialize a parameter of type 'CGColor *' with an rvalue of type 'CGColorRef' (aka 'CGColor *')
error: 1 errors parsing expression
(lldb) po [UIColor colorWithCGColor:(CGColor *)cgColor]
error: cannot initialize a parameter of type 'CGColor *' with an rvalue of type 'CGColor *'
error: 1 errors parsing expression
(lldb) po [UIColor colorWithCGColor:(struct CGColor *)cgColor]
error: cannot initialize a parameter of type 'CGColor *' with an rvalue of type 'struct CGColor *'
error: 1 errors parsing expression

那么,如何获取lldb来执行带有CGColorRef类型参数的行?

So, how can I get lldb to execute a line that takes a parameter of type CGColorRef?

推荐答案

我能够使用以下方法使其正常工作:

I was able to get this to work using:

(lldb) po [[UIColor alloc] initWithCGColor:cgColor]
UIDeviceRGBColorSpace 1 0 0 1

来自UIColor.h:

@property(nonatomic,readonly) CGColorRef CGColor;
- (CGColorRef)CGColor NS_RETURNS_INNER_POINTER CF_RETURNS_NOT_RETAINED;

因此,我相信UIColor超出范围,并且.CGColor的内存不再有效.我可能必须复制它,但出于我的目的,使用-initWithCGColor:可以正常工作.

So I believe the UIColor is going out of scope and the memory of the .CGColor is no longer valid. I would probably have to copy it, but for my purposes, using the -initWithCGColor: works fine.

这篇关于无法在LLDB中传递CGColorRef类型的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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