title: ios scratch card effect crash
body: <p>I need to use a scratch effect for my game. here is an example code years ago. </p>
  
  <p><a href="https://github.com/oyiptong/CGScratch">https://github.com/oyiptong/CGScratch</a></p>
  
  <p>It works just fine, but when i use it together with navigation controller, it crashes. </p>
  
  <p>My project uses ARC, i flag the file as -fno-objc-arc. Here is the source code: </p>
  
  <p><a href="https://github.com/lifesaglitch/ScratchWithError">https://github.com/lifesaglitch/ScratchWithError</a></p>
  
  <p>it crashes when i push the view controller, then pop, then reenter. </p>
  
  <p>Edit:</p>
  
  <p>When you convert all to arc, and flag the view controller that uses the scratch view as -fno-objc-arc, it works. But when you flag the scratch view as -fno-objc-arc instead, it crashes again. My project uses arc and i dont think i can convert my own view controller to be -fno-objc-arc. </p>
  
  <p>Edit 2: </p>
  
  <p>I modify the initialization code to: </p>
  
  <pre><code>    scratchable = CGImageRetain([UIImage imageNamed:@"scratchable.jpg"].CGImage);
  </code></pre>
  
  <p>it does not crash anymore, but there's a memory leak. and CGImageRelease did get called once in dealloc method. </p>