McLaughlin, Michael P. <mailto:[email protected]> wrote (Thursday, February 4, 2010 6:47 AM -0500):

solverOp *thisOp = [solverOp new];
[thisOp initWithData:Data];

Wrong. You're initing your object twice! This should be

solverOp *thisOp = [[solverOp alloc] initWithData:Data];

(+new sends an -init, so your code was equivalent to [[[solverOp alloc] init] initWithData:...])

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).

Standard memory management rules apply: the NSOperationQueue retains the NSOperation until it's finished. You need to retain it until you're done with with. For GC, replace "retain" with "reference".

Is the setup code fragment above correct or must NSOperations be retained in
scope explicitly until the operation is finished?

It's OK for GC, but if you're using retained memory you're missing an autorelease.

Fix your init, and you'll probably be OK.

--
James Bucanek

_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to