Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
覆盖控制Swift中的AlternatingRowBackgroundColor_Swift_Macos_Nstableview - Fatal编程技术网

覆盖控制Swift中的AlternatingRowBackgroundColor

覆盖控制Swift中的AlternatingRowBackgroundColor,swift,macos,nstableview,Swift,Macos,Nstableview,我试图找出如何在Swift中覆盖控制AlternatingRowBackgroundColor,但无论我做什么,似乎都会出错 extension NSColor { class var controlAlternatingRowBackgroundColors: [NSColor] { return [NSColor.red, NSColor.blue] } } 这为我提供了使用Objective-C选择器的“ControlAlteratingGrowt

我试图找出如何在Swift中覆盖控制AlternatingRowBackgroundColor,但无论我做什么,似乎都会出错

extension NSColor {

    class var controlAlternatingRowBackgroundColors: [NSColor] {

        return [NSColor.red, NSColor.blue]

    }

}
这为我提供了使用Objective-C选择器的“ControlAlteratingGrowthBackgroundColors”的Getter“ControlAlteratingGrowthBackgroundColors”与使用相同Objective-C选择器的先前声明冲突

如果我使用override,那么我会得到一个错误,说明它不会覆盖任何内容


如果我在objective c中的NSColor上创建了一个类别,它将按预期工作!

可能的重复:您不能覆盖扩展中的属性(在objective-c类别中这样做是未定义的行为).Yep,谢谢。看起来非常相似。不幸的是,它看起来不像这样。有任何方法可以做到这一点,那么我在这个实例中没有子类。可能的重复:您不能覆盖扩展中的属性(并且在Objective-C类别中这样做是未定义的行为).是的,谢谢。看起来很相似。不幸的是,它看起来不像这样。有任何方法可以做到这一点,那么在这个例子中我没有子类。