Let's take a look at these methods.
-(void) end
{
[runningScene_ onExit];
[runningScene_ cleanup];
[runningScene_ release];
runningScene_ = nil;
nextScene = nil;
// remove all objects, but don't release it.
// runWithScene might be executed after 'end'.
[scenesStack_ removeAllObjects];
// don't release the event handlers
// They are needed in case the director is run again
[[TouchDispatcher sharedDispatcher] removeAllDelegates];
[self stopAnimation];
[self detach];
// Purge all managers
[[Scheduler sharedScheduler] release];
[[ActionManager sharedManager] release];
[[TextureMgr sharedTextureMgr] release];
}
- (void) dealloc
{
CCLOG( @"deallocing %@", self);
#if DIRECTOR_DISPLAY_FAST_FPS
[FPSLabel release];
#endif
[runningScene_ release];
[scenesStack_ release];
[openGLView_ release];
_sharedDirector = nil;
[super dealloc];
}
(I know I copied and pasted dealloc instead of release but that's because calling release on the sharedDirector results in deallocating it since it's a singleton)
end is listed under the "scene management" section. It gets rid of the running scene and the scenes in the stack (if you used pushScene). It stops the Director's animation (FPS = 0) and removes its OpenGL view from the application window. It then releases some other singletons : the Scheduler, the ActionManager and the TextureMgr.
release is just a regular release message which is part of the memory management process. It causes the Director to be dealloc'd, which calls release on the objects the Director had retained : no big deal there.
Now, if you wonder which one to call in the applicationWillTerminate function, the answer is none. When the app is about to quit, it's not necessary to clean up the memory by calling release on all your retained objects, because the iPhone OS will reclaim the memory it allocated for your app when you launched it. This is faster and safer than rely on the apps to correctly clean up after themselves. You can verify this by putting an NSLog call (or a debugger breakpoint) in the dealloc method of your application delegate and seeing it's never called.
So, cleaning things up when the app is about to quit is useless. Moreover, you have very limited time before the OS wipes your app out, so don't waste it on cleaning things. Focus on saving your game and any other relevant stuff. Maybe you can call [[Director sharedDirector] stopAnimation] and then save your game. But IMO, calling end is too much.
On the other hand, if some parts of your app are made with cocos and some other parts with UIKit and you need to keep switching between the two, then it's a different story. When you need to remove the cocos stuff, you need both calls :
[[Director sharedDirector] end];
[[Director sharedDirector] release];
And when you need to add the cocos stuff (again), it's exactly the same piece of code as in the applicationDidFinishLaunching method of the application delegate.