• 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
How to cancel an NSInvocationOperation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to cancel an NSInvocationOperation


  • Subject: How to cancel an NSInvocationOperation
  • From: "Gerriet M. Denkmann" <email@hidden>
  • Date: Mon, 16 Apr 2012 16:07:34 +0700

 I have this code:

NSMethodSignature *ms = [ self methodSignatureForSelector: @selector(someMethod:) ];
NSInvocation *inv = [NSInvocation invocationWithMethodSignature: ms ];
[ inv retainArguments ];
[ inv setSelector: @selector(someMethod:) ];
[ inv setTarget: self ];
[ inv setArgument: &a atIndex: 2 ];

NSInvocationOperation *ivo = [ [ NSInvocationOperation alloc ] initWithInvocation: inv ];
[ self.operationQueue  addOperation: ivo ];

Works fine. But the documentation says: "An operation object is responsible for calling [isCanceled] periodically and stopping itself if the method returns YES."

But how do I check for "isCanceled" from within someMethod: ?

Is there something like: +[ NSOperation theOperationThisCodeIsRunningIn ]?

I tried (inside of someMethod:):
NSThread *currentThread = [ NSThread currentThread ];
if ( [ currentThread isCancelled ] ) NSLog(@"%s Cancelled",__FUNCTION__);

But this has no effect.
10.7.3


Kind regards,

Gerriet.



_______________________________________________

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: How to cancel an NSInvocationOperation
      • From: Mike Abdullah <email@hidden>
  • Prev by Date: Re: Question about hebrew in textfields and textviews
  • Next by Date: Fast Enumeration and temporary objects/autoreleasing
  • Previous by thread: Re: Responder chain inclarity
  • Next by thread: Re: How to cancel an NSInvocationOperation
  • Index(es):
    • Date
    • Thread