CAShapeLayer で描写した図形を消すには?

CAShapeLayer で描写した図形を消そうと、

    CAShapeLayer* circleLayer;

    /*

  描写する部分、省略

     */

    [circleLayer removeFromSuperlayer];

とすると、消えない。

 

なんで?と思って調べたら、

    [circleLayer removeFromSuperlayer];

    circleLayer = nil;

とすると消えることが判明。めんどくさいね。

 Apple のリファレンス見たら、

You can use this method to remove a layer (and all of its sublayers) from a layer hierarchy. This method updates both the superlayer’s list of sublayers and sets this layer’s superlayerproperty to nil.

はいはい、ちゃんと書いてあるね。