'NSInternalInconsistencyException: Do not initialize the TextureCache before the Director'-Collection of common programming errors

To find a solution I have gone thru this similar link: TextureCache Error from Cocos2d when integrated into UIKit App but seems like it is dealing with this error in a different context..

Question: I have a UIKit project integrated with Cocos2d. When build, succeeds and runs but, at times crashes after receiving a memory warning with this error:

Assertion failure in -[CCTextureCache init], /Users/MyName/Documents/CSProject/CSProject/libs/cocos2d/CCTextureCache.m:90

Terminating app due to uncaught exception ‘NSInternalInconsistencyException’, reason: ‘Do not initialize the TextureCache before the Director’

The cocos2d scene is run from the view controller when a button is touched and the code is given below:

In ViewController.m

-(IBAction)overToCocos:(id)sender{
    CCDirector *director = [CCDirector sharedDirector];
    CCGLView *glView = [CCGLView viewWithFrame:CGRectMake(-100, -50, 480, 480)
                                   pixelFormat:kEAGLColorFormatRGBA8
                                   depthFormat:0];
    glView.opaque = NO;
    self.imagePicker.cameraOverlayView.userInteractionEnabled = YES;
    [self.imagePicker.cameraOverlayView insertSubview:glView atIndex:0];
    [self.imagePicker.cameraOverlayView bringSubviewToFront:glView];
    [director setView:glView];
    [director runWithScene:[HelloWorldLayer scene]];
}

Since the crash occurs after receiving a memory warning, I tried this

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
    if ( [ CCDirector sharedDirector ].view != nil ){
        [[CCTextureCache sharedTextureCache] removeUnusedTextures];
    }

}

Also added this to AppDelegate’s applicationDidReceiveMemoryWarning. But the crash still exists.. Please point me to the right direction to handle this error..

Thanks in advance!