nsoperation

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

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

NSOperation in iOS - How to handle loops and nested NSOperation call to get Images

蹲街弑〆低调 提交于 2019-12-12 20:08:09
问题 I need help understanding how to appropriate handle the following use case: Say I'm writing a Chat app: Launch App Ask server ( AFHTTPRequestOperation ) to give me a list of all new messages Loop through those messages to see if I need to download any images If yes, then make another call to the server ( AFImageRequestOperation ) to get the image I keep getting crashes where my managed object "message" is no longer in the same context, but I'm only using one managedObjectContext . Is it

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 =

Fixing my network activity indicator

送分小仙女□ 提交于 2019-12-12 09:55:32
问题 I have a problem with my network activity indicator in that sometimes it will continue to be displayed when it should not be. I wrote my own manager for it and swapped it out for one that uses an NSAssert statement like this... - (void)setNetworkActivityIndicatorVisible:(BOOL)setVisible { static NSInteger NumberOfCallsToSetVisible = 0; if (setVisible) NumberOfCallsToSetVisible++; else NumberOfCallsToSetVisible--; // The assertion helps to find programmer errors in activity indicator

CloudKit: CKFetchRecordChangesOperation, CKServerChangeToken and Delta Download

让人想犯罪 __ 提交于 2019-12-12 08:14:28
问题 My question is related to the "Delta Download" thing as it was named in WWDC 2014 Advanced CloudKit. I'm trying to make syncronization for my Core Data app, which is iPhone only for now (think: there is only one device active). So, basically the app will store user records in the cloud from one same device, for the most cases for now. I have trouble with understanding custom zone feature which is based on CKFetchRecordChangesOperation aka Delta Download. As I got it right, we have

Download images in order with AFNetworking

試著忘記壹切 提交于 2019-12-12 05:17:50
问题 How do you download images in order with AFNetworking? An by "in order", I also mean executing the success blocks in order. Initially I thought it would be enough to use a NSOperationQueue and set each AFImageRequestOperation as a dependency of the next one. Like this: - (void) downloadImages { { // Reset [_downloadQueue cancelAllOperations]; _downloadQueue = [[NSOperationQueue alloc] init]; _images = [NSMutableArray array]; } AFImageRequestOperation *previousOperation = nil; for (NSInteger i

How to work with NSOperationQueue and NSBlockOperation with dispatch gcd?

两盒软妹~` 提交于 2019-12-12 03:17:40
问题 Here is the code @interface ViewController () @property (nonatomic, strong) NSOperationQueue *queue; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; _queue = [[NSOperationQueue alloc] init]; NSBlockOperation *aBlockOperation = [[NSBlockOperation alloc] init]; __weak NSBlockOperation* aWeakBlockOperation = aBlockOperation; [aBlockOperation addExecutionBlock:^{ NSLog(@"queue should still have the operation. And it does. yay!: %@", [_queue operations]); // This

Crashing issue due to memory management (using Core Data)

放肆的年华 提交于 2019-12-12 02:22:55
问题 I am using Core Data. From there i am retrieving 10000+ data Using NSOperation, i am displaying huge data on UITableView. but as i can see in XCode Instruments my memory usage continuously increasing thats the reason, crashing activity is there in device not in simulator Any one would like to comment on this ? 回答1: Don't retrieve 10000 objects at once. Use the NSAutoreleasePool and flush the pool at some consistent interval (interval to be determined via testing). Every N iterations: save