FAQ Database Discussion Community


NSOperationQueue blocks UITableView

ios,objective-c,sqlite,uitableview,nsoperationqueue
The following code is by another employee at my company, but i have to solve the performance-issue now... The method deleteObjectAndAllDependencies deletes the project and the related data from our SQLite DB... The tableView isn't usable still everything is performed. How can I speed up this process? Without using functionality....

Concurrent NSOperation and how to set isFinished and isExecuting?

ios,xcode,nsoperation,nsoperationqueue
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 and NSOperationQueue with maxConcurrentOperationCount = 1

ios,nsoperation,nsoperationqueue
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 cancelAllOperations not work when viewWillDisappear

ios,objective-c,nsoperation,nsoperationqueue
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...

Does this code produce 2 NSTimers instead of 1?

xcode,nstimer,nsoperationqueue
I am creating a work queue to perform tasks in the background. The code is below. The problem is that selector called by the timer is called twice every period, by 2 different timers. The queue (UpdateController) is created in didFinishLaunchingWithOptions of the AppDelegate: ... [self setUpdateController:[[FFUpdateController alloc] initWithRootDetailViewController:rdvc]]; [[self...

Using new features while supporting older iOS versions

ios,objective-c,ios8,nsoperationqueue,legacy-code
I am developing an app using SDK 8.1, Apple LLVM 6.0 and Xcode 6.1.1. The deployment target is 6.0. I'm using NSOperationQueue and I want to use QoS whenever it's available. The code I'm using is: if ([self.operationQueue respondsToSelector:@selector(setQualityOfService:)] && (&NSOperationQualityOfServiceUserInitiated)) { [self.operationQueue performSelector:@selector(setQualityOfService:) withObject: NSOperationQualityOfServiceUserInitiated]; } else { //Other...

NSOperationQueue addOperations waitUntilFinished

ios,swift,nsoperation,nsoperationqueue
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...

NSOperationQueue gets complete notification before completing tasks

ios,objective-c,objective-c-blocks,nsoperation,nsoperationqueue
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...

Handling UI update in a for loop - iOS

ios,objective-c,nsnotificationcenter,nsoperationqueue
I'm using NSNotificationcentre to update the UI from a for loop. The UI isn't updated until the execution is out of the loop. Is there way to handle this case? Here is my code below: - (void)uploadContent{ NSURLResponse *res = nil; NSError *err = nil; for (int i = 0;...

NSAttributedString initWithData and NSHTMLTextDocumentType crash if not on main thread

ios,cocoa,cocoa-touch,nsattributedstring,nsoperationqueue
calling NSAttributedString * as = [[NSAttributedString alloc] initWithData:[htmlString dataUsingEncoding:NSUTF8StringEncoding] options:@{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType, NSCharacterEncodingDocumentAttribute: @(NSUTF8StringEncoding)} documentAttributes:nil error:nil]; on other than main thread, results in a crash 1 0x194b861fc <redacted> 2 0x19801d31c <redacted> 3 0x198010eb4 _os_once 4 0x19801aa2c pthread_once 5 0x195a0858c <redacted> 6 0x195a07c78 WebKitInitialize 7 0x18bb38918 <redacted> 8...

Do I have to read NSOperationQueue's operationCount on the operation queue itself?

ios,nsoperationqueue
Sometimes it seems operationCount does not return the right value. Do I have to access it from the queue itself or it does not matter if I access it from an other thread?

Correct asynchronous Authentication while keeping a responsive UI

swift,asynchronous,nsurlrequest,nsoperationqueue
What it's supposed to be I have a username field. When the username is entered and the sendButton is clicked, the userdata is fetched with a asynchronousRequest as a JSON file. After the sendButton is clicked, I want to display an ActivityIndicator. The UI shall still be responsive, while the...

Is it safe to use GCD to open a socket connection on iOS, even with a complex stack?

ios,sockets,grand-central-dispatch,nsoperationqueue
I have an iOS app with which I was previously using performSelectorInBackground to open a persistent socket connection. However, according to this answer, one should never use performSelectorInBackground. The alternative, GCD and NSOperationQueue, both appear to persist the full stack frame, including 4! separate context switches, when I pause my...

iOS concurrency: NSOperationQueue and ARC issue

objective-c,multithreading,concurrency,automatic-ref-counting,nsoperationqueue
I am currently implementing a multithreaded application and I encounter a strange race condition (leading to an ARC problem: error for object 0x7f8bcbd6a1c0: pointer being freed was not allocated). The app creates multiple NSOperations, each one is downloading and processing information. As in every one of these NSOperations an error...

CoreAnimation warning when updating NSProgressIndicator via a block executed on main queue

osx,cocoa,core-animation,nsoperationqueue,nsprogressindicator
I have the following scenario for exporting Core Data entities to JSON and displaying a progress bar while doing so. Sometimes, after the sheet with the progress bar is dismissed when the export is completed, i get the follwing warning as a console message: CoreAnimation: warning, deleted thread with uncommitted...

NSOperation & NSOperationQueue Cancellation

ios,objective-c,nsoperation,nsoperationqueue
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...