• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Scope of NSOperations
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Scope of NSOperations
      • From: Jens Alfke <email@hidden>
    • Re: Scope of NSOperations
      • From: James Bucanek <email@hidden>
  • Prev by Date: Yong Li has invited you to Dropbox
  • Next by Date: Re: Scope of NSOperations
  • Previous by thread: [Moderator] DO NOT RESPOND: Yong Li has invited you to Dropbox
  • Next by thread: Re: Scope of NSOperations
  • Index(es):
    • Date
    • Thread