I created an EOEditingContext and release it but its not gone
From EOFWiki
#import <Foundation/Foundation.h>
#import <Foundation/NSDebug.h>
#import <EOControl/EOControl.h>
int main (int argc, const char * argv[])
{
NSAutoreleasePool *pool;
EOEditingContext *ec;
EOGenericRecord *record;
NSZombieEnabled = YES;
pool = [NSAutoreleasePool new];
record = [[[EOGenericRecord alloc] initWithEditingContext:nil
classDescription:[[EOClassDescription new] autorelease]
globalID:nil] autorelease];
ec = [EOEditingContext new]; // RC 1
[ec insertObject:record];
[ec release]; // RC 0 ?
NSLog( @"-[ec retainCount] = %u", [ec retainCount]);
[pool release];
return( 0);
}
One would probably expect that this code crashes horribly. Yet the output of this program is
2008-01-17 17:54:51.242 ECDontVanish[15904] -[ec retainCount] = 1
The solution to the puzzle is that edits are queued in the EOEditingContext and processed in a delayed manner. For that the EOEditingContext hooks into the NSRunLoop, which will retain the context. This can be a pain for tool applications, that do not utilize the NSRunLoop, yet Foundation nevertheless sets one up.
TODO: You can use EOEditingContextDontProcessChangesInRunloop to not register, also check the -processChangesImmediately flag.