Orangekay can you point me to the document that tells me that "Pools can be drained at any time"? From what I have read it only happens at very well defined points, namely when the pool is destroyed. Remember that in Cocoa Touch drain == release for pools.
As to your snippet - I think you missed the point of the discussion. It is expected that once UIApplicationMain is called there is a Cocoa supported run loop in place that will clean up its own pools. I suspect you created the MyDocument object after the Cocoa run loop was set up in which case Cocoa is cleaning up after you as expected. Or perhaps you were running in a garbage collected environment in which case there is no need for autorelease pools.
The claim is that the pool created outside the Cocoa run loop will not be cleaned up until it is released since the rules outlined in the documents on autorelease pools are followed. As further evidence try running the following as a Cocoa Touch application.
#ifndef TARGETOSIPHONE
#import <Cocoa/Cocoa.h>
#endif
@interface Evidence : NSObject
{
}
@end
@implementation Evidence
- (id) init
{
if (self = [super init])
{
NSLog(@"Evidence lives");
}
return self;
}
- (void) dealloc
{
NSLog(@"Evidence has been autoreleased");
[super dealloc];
}
@end
int main(int argc, char *argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
Evidence *debunker = [[[Evidence alloc] init] autorelease];
#if TARGETOSIPHONE
int retVal = UIApplicationMain(argc, argv, nil, nil);
#else
int retVal = NSApplicationMain(argc, (const char **) argv);
#endif
[pool release];
return retVal;
}