Ios 是否可以使用Swift进行KVC?

Ios 是否可以使用Swift进行KVC?,ios,objective-c,swift,key-value-coding,caemittercell,Ios,Objective C,Swift,Key Value Coding,Caemittercell,我试图在Swift中创建以下Objective-C的等效项 [emitterLayer setValue:@ (scale) forKeyPath:@"emitterCells.cell.emitterCells.childCell.scale"]; 我在Swift中尝试了以下方法: emitterLayer.setValue (scale), forKey: "emitterCells.cell.emitterCells.childCell.scale") 但是,这不会像在objectiv

我试图在Swift中创建以下Objective-C的等效项

[emitterLayer setValue:@ (scale) forKeyPath:@"emitterCells.cell.emitterCells.childCell.scale"];
我在Swift中尝试了以下方法:

emitterLayer.setValue (scale), forKey: "emitterCells.cell.emitterCells.childCell.scale")
但是,这不会像在objective-C中那样改变该值


这在Swift中有效吗?或者我需要重构它以实现相同的结果吗?

它应该有效,但语法是

emitterKayer.setValue(scale, 
  forKeyPath:  "emitterCells.cell.emitterCells.childCell.scale")

scale
是一种值类型吗?用
NSNumber
forKey
vs.
forKeyPath
包装它?这是KVC,不是KVO。