title: Core Animation - modify animation property
body: <p>I have animation</p>
  
  <pre><code> func startRotate360() {
      let rotation : CABasicAnimation = CABasicAnimation(keyPath: "transform.rotation.z")
      rotation.fromValue = 0
      rotation.toValue =  Double.pi * 2
      rotation.duration = 1
      rotation.isCumulative = true
      rotation.repeatCount = Float.greatestFiniteMagnitude
      self.layer.add(rotation, forKey: "rotationAnimation")
  }
  </code></pre>
  
  <p>What I want is ability to stop animation by setting its repeat count to 1, so it completes current rotation (simply remove animation is not ok because it looks not good)</p>
  
  <p>I try following</p>
  
  <pre><code>func stopRotate360() {
      self.layer.animation(forKey: "rotationAnimation")?.repeatCount = 1
  }
  </code></pre>
  
  <p>But I get crash and in console</p>
  
  <blockquote>
    <p>attempting to modify read-only animation</p>
  </blockquote>
  
  <p>How to access writable properties ?</p>