nsoperation

runAction on SKNode does not complete

人走茶凉 提交于 2019-12-19 11:53:44
问题 I use a subclass NSOperation to obtain serial execution of SKAction as described in this question: How to subclass NSOperation in Swift to queue SKAction objects for serial execution? I then modified the previous subclass in order to group animations for several nodes: https://stackoverflow.com/a/30600718/540780 At last, as I needed to run completion block after SKAction completed, I slightly modified the code by using an array of struct instead an array of tuples. struct ActionData { let

Executing the NSOperation when all other operations in NSOperationQueue finished no matter whether they finished successfully or not

早过忘川 提交于 2019-12-19 04:06:23
问题 Hi I have a strange situation here : OverView: I am working on an app where user can initiate multiple operations and all these operations will run on a background thread hence will not block the UI. Some of these operations are dependent on each other and some are not. So in order to ensure that operation will execute only after all the necessary dependencies operations finished executing am using the dependency property of Operation. I am making use of Asynchronous operations. Here is my

Return data from NSOperation?

浪子不回头ぞ 提交于 2019-12-18 16:54:37
问题 I'm creating a lot of NSOperation s (subclasses) that sort through a bunch of data. When they're done, I'd like them "return" that data and put it into a mutable array or something. Order doesn't matter. Is something like this is possible? 回答1: Sure. Declare a delegate in NSOperation subclass. Then after finish of operation if([self.delegate respondsToSelector:@selector(YourDelegate:)]) { [(NSObject *)self.delegate performSelectorOnMainThread:@selector(YourDelegate:) withObject:self

Wait for all Operations in queue to finish before performing task

混江龙づ霸主 提交于 2019-12-18 15:54:15
问题 I have an Operation subclass and Operation queue with maxConcurrentOperationCount = 1. This performs my operations in a sequential order that i add them which is good but now i need to wait until all operations have finished before running another process. i was trying to use notification group but as this is run in a for loop as soon as the operations have been added to the queue the notification group fires.. How do i wait for all operations to leave the queue before running another process

Asynchronous url requests inside dispatch_async

青春壹個敷衍的年華 提交于 2019-12-18 11:15:12
问题 I am trying to implement asynchronous url requests in a particular function, I want all these requests to complete and then do a particular action but the action precedes the requests i.e, it is getting called before the requests complete. dispatch_queue_t fetchQ = dispatch_queue_create("Featured Doc Downloader", NULL); dispatch_async(fetchQ, ^{ [self myAsyncMultipleURLRequestFunction]; dispatch_sync(dispatch_get_main_queue(), ^{ [self updateUIFunction]; }); }); -(void

CoreAnimation warning deleted thread with uncommitted CATransaction

烂漫一生 提交于 2019-12-18 10:46:35
问题 I am having issues with the following warning: CoreAnimation: warning, deleted thread with uncommitted CATransaction; set CA_DEBUG_TRANSACTIONS=1 in environment to log backtraces. I am using an NSOperation object to perform some calculations, once complete it sends a message back to the AppDelegate that then hides a progress bar and unhides some buttons. If I comment out the message back to the AppDelegate the warning goes away but the progress bar obviously remains visible and animated. I am

NSOperation property overrides (isExecuting / isFinished)

北城以北 提交于 2019-12-18 10:23:16
问题 I am subclassing NSOperation in Swift and need to override the isExecuting and isFinished properties since I am overriding the start method. The problem I run into is how to preserve key-value observing (KVO) while also being able to override these properties. Normally in Obj-C this would be rather easy to redeclare the properties as readwrite in the class extension JSONOperation () definition. However, I don't see this same capability in Swift. Example: class JSONOperation : NSOperation,

How to subclass NSOperation in Swift to queue SKAction objects for serial execution?

99封情书 提交于 2019-12-18 08:32:44
问题 Rob provided a great Objective-C solution for subclassing NSOperation to achieve a serial queuing mechanism for SKAction objects. I implemented this successfully in my own Swift project. import SpriteKit class ActionOperation : NSOperation { let _node: SKNode // The sprite node on which an action is to be performed let _action: SKAction // The action to perform on the sprite node var _finished = false // Our read-write mirror of the super's read-only finished property var _executing = false /

NSOperation and NSNotificationCenter on the main thread

社会主义新天地 提交于 2019-12-17 23:29:27
问题 I have an NSOperation. When it is finished I fire a NSNotificationCenter to let the program know that the NSoperation is finished and to update the gui. To my understanding listeners to the NSNotification will not run on the main thread because the NSOperation is not on the main thread. How can I make it so that the listeners run on the main thread when I fire my event? [[NSNotificationCenter defaultCenter] postNotificationName:@"myEventName" object:self]; 回答1: You can use

Asynchronous methods in NSOperation

旧巷老猫 提交于 2019-12-17 17:37:04
问题 I'm fetching some data from Facebook Connect (using the FBConnect Objective-C 2.0 framework) and I'm doing all that in an NSOperation. It is in an NSOperation because I have several other operations that run as well and this is one of them. The problem is that all the FBConnect calls are asynchronous. Because of this, the main method of the NSOperation quickly finishes and the operation is marked as completed. Is there some way to overcome this? It would appear there are no synchronous