Dinalli Dinalli - 1 year ago 100
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?

Answer Source

It should work, but the syntax would be

  forKeyPath:  "emitterCells.cell.emitterCells.childCell.scale")
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download