gpt4 book ai didi

objective-c - Obj-C 选择器在属性上无法识别?

转载 作者:行者123 更新时间:2023-12-03 17:37:03 25 4
gpt4 key购买 nike

我在尝试设置属性时收到 NSObject doesNotRecognizeSelector 错误,但我不确定原因。

错误发生在setWithNSColor的第一行。我有点困惑为什么正确合成的属性可能无法被识别。

@interface ScopeColor : NSObject {
NSString *colorIntegerString;
float redColor;
float greenColor;
float blueColor;
NSString *name;
}

@property (readwrite, assign) NSString *colorIntegerString;
@property (readwrite, assign) float redColor;
@property (readwrite, assign) float greenColor;
@property (readwrite, assign) float blueColor;
@property (readwrite, assign) NSString *name;

-(void)setWithNSColor:(NSColor *)inColor
{
self.redColor=[inColor redComponent];
self.greenColor=[inColor greenComponent];
self.blueColor=[inColor blueComponent];
}

最佳答案

您确定是您的类(class)而不是 NSColor 引发了异常吗?如果 NSColor 对象不属于 NSCalibrateRGBColorSpace 或 NSDeviceRGBColorSpace,则请求 redComponent 等将引发异常。

关于objective-c - Obj-C 选择器在属性上无法识别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1964086/

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