title: deleting shaders in cocos2d 2.1
body: <p>I have a subclassed sprite with a custom shader in a cocos2d 2.1 / kobold2d project (ARC enabled). i'm getting a crash in CCGLProgram when changing scenes. dealloc is being called and i crash on an NSAssert that:
  'Vertex Shaders should have been already deleted'</p>
  
  <p>the shader is defined first as CCGLProgam object "theShaderProgram" and is declared as an instance variable in the header file and defined in the init method.</p>
  
  <p>the shader is called at some point with:</p>
  
  <pre><code>[self shaderOn:self];
  </code></pre>
  
  <p>via the method:</p>
  
  <pre><code>-(void) shaderOn:(CCNode*)noder {
  
    noder.shaderProgram = theShaderProgram;
    [noder.shaderProgram addAttribute:kCCAttributeNamePosition index:kCCVertexAttrib_Position ];
    [noder.shaderProgram addAttribute:kCCAttributeNameTexCoord index:kCCVertexAttrib_TexCoords ];
    [noder.shaderProgram link ];
    [noder.shaderProgram updateUniforms ];
  
    }
  </code></pre>
  
  <p>i tried adding:</p>
  
  <pre><code>-(void) onExit {
  
     self.shaderProgram = [[CCShaderCache sharedShaderCache] programForKey:kCCShader_PositionTextureColor]; 
     }
  </code></pre>
  
  <p>for reference, my shader is from birkemose over at cocos2d:</p>
  
  <pre><code>  theShaderProgram = [[CCGLProgram alloc]
                                    initWithVertexShaderByteArray:
                                    " \n\
                                    attribute vec4 a_position; \n\
                                    attribute vec2 a_texCoord; \n\
                                    \n\
                                    varying vec2 v_texCoord; \n\
                                    \n\
                                    void main( ) { \n\
                                    gl_Position = CC_MVPMatrix * a_position; \n\
                                    v_texCoord = a_texCoord; \n\
                                    } \n\
                                    "
                                    fragmentShaderByteArray:
                                    " \n\
                                    uniform sampler2D CC_Texture0; \n\
                                    \n\
                                    varying vec2 v_texCoord; \n\
                                    \n\
                                    void main( ) { \n\
                                    // old default shader \n\
                                    // gl_FragColor = texture2D( CC_Texture0, v_texCoord ); \n\
                                    // new greyscale shader \n\
                                    vec4 color = texture2D( CC_Texture0, v_texCoord ); \n\
                                    float grey = color.r * 0.212 + color.g * 0.715 + color.b * 0.072; \n\
                                    gl_FragColor = vec4( grey, grey, grey, color.a );  \n\
                                    } \n\
                                    "
                                    ];
  </code></pre>