nsoperationqueue

Is the following a safe use of dispatch_set_target_queue()?

℡╲_俬逩灬. 提交于 2019-12-16 18:07:08
问题 What I want to do is create an indirect queue targeting the main queue. dispatch_queue_t myQueue = dispatch_queue_create("com.mydomain.my-main-queue", NULL); dispatch_set_target_queue(myQueue, dispatch_get_main_queue()); My ultimate goal is to use the queue as the underlyingQueue property of an NSOperationQueue, because Apple's documentation clearly states not to use dispatch_get_main_queue(). Though using an indirect queue it technically is following the documentation. The reason for all

How to make simultaneous https requests in Swift 3

有些话、适合烂在心里 提交于 2019-12-13 12:15:54
问题 I'm having problems to execute a https requests, if the request don't have any error i never get the message, this is a command line tool application and i have a plist to allow http requests, i always see the completion block. typealias escHandler = ( URLResponse?, Data? ) -> Void func getRequest(url : URL, _ handler : @escaping escHandler){ let session = URLSession.shared var request = URLRequest(url:url) request.cachePolicy = .reloadIgnoringLocalCacheData request.httpMethod = "GET" let

check when two NSOperationQueue have finished to call endBackgroundTask for stopping background task mode

你离开我真会死。 提交于 2019-12-13 06:27:28
问题 in my app i have some NSOperation that update some core data element from a online database, sometime the update require some minute, and when the screen of iPhone lock, the app enter in the background mode, and this update is stopped, so i have to reopen the app to continue the update, so i have asked this some minute ago on SO, i have received this correct answer: - (void)someMethodToKeepRunningInBackground { UIBackgroundTaskIdentifier taskId = [[UIApplication sharedApplication]

Concurrent NSOperation and how to set isFinished and isExecuting?

久未见 提交于 2019-12-13 04:42:37
问题 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 using an NSQueue and add a displayMessages operation to it and then a deleteMessages operation (named MyOperation below). I understand that concurrent operations means they will only execute one after another in a queue

NSOperationQueue with synchronous NSURLConnection

女生的网名这么多〃 提交于 2019-12-13 04:35:30
问题 Building on an earlier question: I have an NSOperationQueue that looks like this: NSBlockOperation *block1 = [NSBlockOperation blockOperationWithBlock:^{ [someObject someSelector]; }]; NSBlockOperation *block2= [NSBlockOperation blockOperationWithBlock:^{ [someObject anotherSelector]; }]; [block2 addDependency:block1]; [queue addOperation:block1]; [queue addOperation:block2]; Now, inside someSelector I have: returnData = [requesterObj getDataWithURL:(NSString*)url]; where getDataWithURL

Cancel NSOperation

蓝咒 提交于 2019-12-13 03:36:16
问题 I am using the following code in a loop: -(void)getUpdatedComments { if(checkComments) { objParseOperation=[[ParseOperation alloc] initWithUDID:[[NSUserDefaults standardUserDefaults] valueForKey:kDeviceUDID]:self]; [operationQueue addOperation:objParseOperation3]; } } where operationQueue is an object of type NSOperationQueue. I am calling this method every few seconds. If I call this method after the first time, do I need to cancel the previous operation or just do [objParseOperation release

NSoperation and key value observing

三世轮回 提交于 2019-12-13 02:32:11
问题 I am creating a MyOperation object (inherited from NSOperation) and add to a NSOperationQueue. Then I am doing KVO on MyOperation. I am using this method - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context; to get a value from MyOperation if it is finished. In this method I am using a convenience method from an other class to get some other data. Maybe here synchronization problems in the observeValue... method? 回答1: I

How can I know which ViewController is active?

萝らか妹 提交于 2019-12-12 22:33:44
问题 I am downloading images using NSOperationQueue. I want to call a method reloadView of my view controller once the image download is complete. However when the download is in progress, it is fairly possible that user has moved to a different view. This other view will also have a reloadView method (e.g. first view shows total downloaded images count, and second shows thumbnails of download images) Basically what I want is that whenever an image download is completed, I should be able to call

how to properly use autoreleasepool for an nsoperationqueue

狂风中的少年 提交于 2019-12-12 18:41:35
问题 I have an app that I am refactoring and I just implemented multithreading so that the UI may run smoother. In the iphone simulator I don't get any leaks but testing on my iPhone 3G running on iOS 4.2 I get a memory leak. I have done a lot of searching for the correct way to implement an autoreleasepool with an operationqueue, help will be greatly appreciated. I have created an nsoperationqueue in my viewcontroller as such - (void)loadData { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]

How can I download datas from multiple URL in concurrency mode?

时光总嘲笑我的痴心妄想 提交于 2019-12-12 10:18:16
问题 I have tried this link for download only one URL. Successfully working for pause and resume too. Now I am trying for multiple URL (i.e, for 5 URL). If 2nd URL is progressing, on that time if I start third URL means, 2nd is stopped. I don't know to run all url in concurrency. I have tried with NSOperationQueue. But I don't know exact syntax and also I don't know how to add task in Queue. There should not be any interruption between my URL links. How to do that? My code: var dict =