Re: rerunning an NSOperation object
Re: rerunning an NSOperation object
- Subject: Re: rerunning an NSOperation object
- From: Robert Monaghan <email@hidden>
- Date: Sun, 06 Mar 2011 19:26:40 +0100
Hi Shane,
NSOperationQueue will not let you re-run a previously run NSOperation Object.
What I did to get around the problem was to create my own NSObject that does what I want. I then wrapped the object with an NSOperation object to run. Once complete, I can simply re-use my NSObject by wrapping a new NSOperation object around it and feeding it to NSOperationQueue. It works like a charm!
bob.
On Mar 6, 2011, at 4:33 AM, Shane wrote:
> I have an NSOperation object that has been placed in an
> NSOperationQueue. I then execute that NSOperation and all works
> normal.
>
> What I'd like to do is then run that task again, however, when I do
> run it I get the following error when trying to add that object to the
> queue again.
>
> Caught NSInvalidArgumentException*** -[NSOperationQueue
> addOperation:]: operation is finished and cannot be enqueued
>
> I then see that the "NSOperationQueue Class Reference" says this about
> addOperation: ...
> "Similarly, this method throws an NSInvalidArgumentException exception
> if the operation is currently executing or has already finished
> executing."
>
> So it has finished executing, and I'd like to know how to execute it
> again but w/o having to build a new object. Is there a way to rerun an
> NSOperation object, or should I do something else besides call
> addOperation: again?
> _______________________________________________
>
> 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
_______________________________________________
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