-2

I am attempting to to change properties on a CAEmitterLayer instance dynamically. I am making a call to setValue:forKey: like this: [self.mainViewController.mainView.spaceView.emitterLayer setValue:[NSNumber numberWithFloat:0] forKey:@"emitterCells.particle.velocityRange"]; but I am not seeing any change in the particle emitter. If i set that property to 0 by hard coding it no particles are emitted. Here is a link to a gist file containing the UIView that implements the particle system. I know KVC can be tricky with miss typing something so maybe I'm simply over-looking something obvious?

1 Answers1

1

so maybe I'm simply over-looking something obvious

Indeed. The problem is this line:

setValue:[NSNumber numberWithFloat:0] forKey:@"emitterCells.particle.velocityRange"

The string "emitterCells.particle.velocityRange" is not a key.

It is a key path. You need to call setValue:forKeyPath:.

matt
  • 515,959
  • 87
  • 875
  • 1,141