Dinalli Dinalli - 8 months ago 18
Swift Question

Is KVC possible with Swift?

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?


It should work, but the syntax would be

  forKeyPath:  "emitterCells.cell.emitterCells.childCell.scale")