Scope of NSOperations
Scope of NSOperations
- Subject: Scope of NSOperations
- From: "McLaughlin, Michael P." <email@hidden>
- Date: Thu, 4 Feb 2010 08:47:56 -0500
- Acceptlanguage: en-US
- Thread-topic: Scope of NSOperations
My (Leopard) app needs to create a sequence of NSOperations, often thousands
of them, a few at a time. The relevant code is in a setup function that
ends with
for (k = 0;k < numOps;k++) {
solverOp *thisOp = [solverOp new];
[thisOp initWithData:Data];
[opQueue addOperation:thisOp];
}
at which point the setup code exits.
I had always *assumed* that, since an NSOperation was allocated (not just
declared), it would automatically persist long enough to do its job -- in
other words, with GC supported, retain count would trump "scope" (as above).
However, I cannot find any sample code that exemplifies this so I became
concerned that it might not be true.
Is the setup code fragment above correct or must NSOperations be retained in
scope explicitly until the operation is finished?
TIA.
--
Mike McLaughlin
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden