Is KVC possible with Swift?

550 Views Asked by At

I'm trying to create the equivalent of the following Objective-C in Swift.

[emitterLayer setValue:@ (scale) forKeyPath:@"emitterCells.cell.emitterCells.childCell.scale"];

I have tried the following in Swift:

emitterLayer.setValue (scale), forKey: "emitterCells.cell.emitterCells.childCell.scale")

However this does not change the value as it would in objective-C

Does this work in Swift or do I need to refactor this to work differently to achieve the same result?

1

There are 1 best solutions below

0
On BEST ANSWER

It should work, but the syntax would be

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