• 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
Canceling NSInvocationOperation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Canceling NSInvocationOperation


  • Subject: Canceling NSInvocationOperation
  • From: Chase Latta <email@hidden>
  • Date: Sat, 12 Feb 2011 12:43:26 -0800

Hello all,

I have run into a situation that I don't quite have a solution for.  I
have a UIScrollView that holds a bunch of CALayers.  My controller is
set up to check and see if it can cache layers that are offscreen
after the user scrolls a certain amount.  I found that doing this on
the main thread was causing my scrolling to not be very smooth so I
decided to use NSInvocationOperations to figure out what can be cached
in an operation queue.

Everything is working fine but I am not sure how I deal with canceling
the operation.  If I were subclassing NSOperation I would simply check
to see if [self isCancelled] returned true and go from there but if I
throw this into my method that I am passing to the
NSInvocationOperation I will just be calling this on my controller
object.  I guess the root of my question is how do I access the
operation from within my method that I am passing to
initWithTarget:selector:object when I create my invocation operation?
I guess I could just create a subclass of NSOperation but I would like
to avoid this because I think it would be overkill.
---------------------------
// Some Code:
- (void)myOperationInController;
{
    // Do stuff
    if (![self isCancelled])  // <---- I need to access the operation
here, self refers to my controller
        [self performSelectorOnMainThread...]
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    // Note: I am not creating an operation every time the user
scrolls in my actual application
    NSInvocationOperation *op = [[NSInvocationOperation alloc]
initWithTarget:self selector:@selector(myOperationInController)
object:nil];
    [self.oprationQueue addOperation:op];
    [op release];
}

---------------------------


Thanks in advance,
Chase
_______________________________________________

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: Canceling NSInvocationOperation
      • From: James Montgomerie <email@hidden>
    • Re: Canceling NSInvocationOperation
      • From: claw <email@hidden>
  • Prev by Date: Re: subclass says "unrecognized selector"
  • Next by Date: Re: Canceling NSInvocationOperation
  • Previous by thread: Re: Sleep Notification
  • Next by thread: Re: Canceling NSInvocationOperation
  • Index(es):
    • Date
    • Thread