FAQ Database Discussion Community

CKFetchRecordsOperation + CKQueryOperations … what am I missing?

Managed to cobble together a CKFetchRecordsOperation after much searching for sample code; and here it is... but I must have missed something. Don't get me wrong it works a treat... but... To execute a CKFetchRecordsOperation you need an NSArray of CKRecordIDs; to get a NSArray of CKRecordIDs, you need to...

Concurrent NSOperation and how to set isFinished and isExecuting?

I am trying to split up my programs flow using NSOperations. I am using the Parse framework to make a simple messaging app. I want to display some messages and then delete them. The display messages shouldn't be called unless the delete operations is finished so I want to try...

NSOperation wait for event

I'd like to make a custom class that extends NSOperation in order to make successful communication with another device by bluetooth. The question I have is how can I implement the main method of the class so that it will wait for an event triggered by the bluetooth?

How to not crash your app on quit when using concurrency

I'm using NSOperationQueue and a subclass of NSOperation for a part in my app that is generating a lot of data and therefore is very calculation-heavy. When the app is closed by the user processingQueue.cancelAllOperations() is called. Also in my NSOperation subclass I overwrote cancel() to let it forward a...

thread_info returns MACH_SEND_INVALID_DEST instead of KERN_SUCCESS

A call to thread_info now returns MACH_SEND_INVALID_DEST instead of KERN_SUCCESS and I don't yet understand what has caused this new circumstance. What could be the reason for this return value. I pass a valid obtained from mach_thread_self() when called inside an NSOperation as thread_act_t (i.e first parameter). At the time...

Is it ok to override completionBlock property of NSOperation with different parameter types?

Marcus Zarra's "Core Data" (2nd edition) book lists an example where in an NSOperation subclass he overrides the completionBlock property: @property (copy) void (^completionBlock)(void) NS_AVAILABLE(10_6, 4_0); with typedef void (^ExportCompletionBlock)(NSData *jsonData, NSError *error); @property (nonatomic, copy) ExportCompletionBlock completionBlock; which in Xcode 6 under 10.10 results in the following warnings: ‘atomic’...

NSOperationQueue gets complete notification before completing tasks

I am using NSOperation subclass in my app which will do following 4 tasks in a single operation, i wanted all these 4 tasks to run on background thread so I wrapped up into single NSOperation class, so that I can easily either pause or cancel it Tasks long time...

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

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...

NSOperationQueue cancelAllOperations not work when viewWillDisappear

My code: NSOperationQueue *queue; -(void)viewDidLoad { queue = [NSOperationQueue new]; NSOperation* loadImgOp = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(refresh) object:nil]; [queue addOperation:loadImgOp]; } -(void)refresh { [self operationFirst]; [self operationSecond]; ... [self operationFive]; dispatch_async(dispatch_get_main_queue(), ^{ [self.tableView reloadData]; }); } - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; [queue cancelAllOperations]; } When I call new...

NSOperation and NSOperationQueue with maxConcurrentOperationCount = 1

I wanted to implement a serial queue with NSOperationQueue.So I have set maxConcurrentOperationCount = 1 for my NSOperationQueue. So couple of question now Now do I still need to set concurrent to YES in subclass NSOperation to make it serial? If I set concurrent to YES for NSOperation, though the...

NSOperationQueue addOperations waitUntilFinished

Hi I am building an app using Swift. I need to process notifications in a specific order. Therefore I am trying to use addOperations waitUntilFinished. Here is what I did: let oldify = NSOperation() oldify.completionBlock = { println("oldify") } let appendify = NSOperation() appendify.completionBlock = { println("appendify") } let nettoyify...

NSOperation & NSOperationQueue Cancellation

I'm encountering some weird issues with some custom NSOperation instances queued in an NSOperationQueue instance: When I call either [myOperation cancel] or [myOperationQueue cancelAllOperations] the isCancelled getter for the cancel boolean remains unchanged for my custom NSOperation subclass instances. I'm trying to cancel the operations when the app delegate applicationWillResignActive...