Reputation: 289
I need to use a library which is not woking properly. After calling some method it creates some NSOperation
, which never finishes and ends up with sleeping state mach_msg_trap
error and as because I don't have the instance of these operations, I'm unable to cancel it.
Is it possible to cancel it without access?
Upvotes: 0
Views: 59
Reputation: 299275
Note that even if you had access to the NSOperation
or its queue, "cancel" doesn't mean "make go away." It just means "don't start if it hasn't been started yet, and if it has been started, set the cancel flag." If the NSOperation
doesn't check its cancel flag, then it still won't terminate. There's no way to do what you're trying to do, and this is intentional. Forcibly terminating an operation would leave the program in an undefined state.
It sounds like you either have a bug in the library, or a bug in how you're using the library (I would suspect the latter before the former, but it depends on the library). You're going to need to track down that bug and resolve it.
Upvotes: 3
Reputation: 7113
Do you have access to the NSOperationQueue
where these Operations have been added?
If yes, you can access like this:
var queue = NSOperationQueue.mainQueue()
// or
queue = NSOperationQueue.currentQueue()!
let operations = queue.operations
for operation in operations{
if operation.name == "name of operation if you know it" {
operation.cancel()
}
}
Upvotes: 0