On 16 Apr 2012, at 10:07, Gerriet M. Denkmann wrote: > 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.
I'm not surprised! Cancelling an operation certainly does not cancel the thread it's running on! If you want your operation to be properly cancellable while running, it's time to subclass NSOperation, rather than use NSInvocationOperation. _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com