Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Incrementing retain count using DO



I'm using DO for thread communication. Here sort of what I'm doing:

//all the same instance

- (IBOutlet)doCalc:(id)sender
{
[NSThread detachNewThreadSelector:@selector(bigMethod:) toTarget:self withObject:portsArray];
//portsArray in an array of NSPorts from an NSConnection initialized at instance init
}

- (void) bigMethod:(NSArray*)inPorts
{
NSAutoreleasePool * thepool=[[NSAutoreleasePool alloc] init];
NSConnection * theConnection=[NSConnection connectionWithReceivePort:[inPorts objectAtIndex:0] sendPort:[inPorts objectAtIndex:1]];
id Proxy=[[theConnection rootProxy] retain];
[Proxy setProtocolForProxy:@protocol(myProto)];
//do calcs
[Proxy reportProgress];
//iterate or finish calcs
[Proxy release];
[thepool release];
}

- (oneway void)reportProgress
{
//report progress
}

The problem is that every time I call doCalc:, my instance's retain count is incremented by one. So after a few runs, the retain count is 4 rather than 1 as it should be. Is there something wrong with my use or something I'm missing? Thanks.




Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.