The NSBlockOperation class is a concrete subclass of NSOperation that manages the concurrent execution of one or more blocks. You can use this object to execute several blocks at once without having to create separate operation objects for each.
Questions tagged [nsblockoperation]
42 questions
1
vote
2 answers
Make BlockOperation fail so that other dependencies don't execute
In a simple case operation2 is dependent on operation1, however operation1 may fail and in this case we don't want to execute operation2
is it possible to deliver a failed execution inside the operation1 code block? so that operation1 fails to…

Peter Lapisu
- 19,915
- 16
- 123
- 179
1
vote
1 answer
Block Operation - Completion Block returning random results
My block operation completion handler is displaying random results. Not sure why. I've read this and all lessons say it is similar to Dispatch Groups in GCD
Please find my code below
import Foundation
let sentence = "I love my car"
let…

Ashh
- 569
- 1
- 6
- 28
1
vote
1 answer
How to know all concurrent NSOperations are completed
My situation is:
I have users
Each user has some history data that can be fetched via user objects
What I want to do is:
Max 2 users must be fetching their history data at the same time (this is the reason that I want to use NSOperationQueue)
I…

Okhan Okbay
- 1,374
- 12
- 26
1
vote
0 answers
CHCSV importer memory issue on NSBlockOperation
I'm on XCode 8.2, Objective-C, OSX (not iOS), ARC enabled.
I'm importing a large CSV file in a custom NSBlockOperation with DaveDelongs CHCSV parser. My problem: The memory is not freed after the operation is done. Even if i do NOT save the parsed…

Pat_Morita
- 3,355
- 3
- 25
- 36
1
vote
0 answers
Is it safe to save parent managed object context in an NSOperation completion
I have an NSOperationQueue that is serial and maxConcurrentOperationCount is set to 1.
I'm creating many operations to process data for CoreData entity modifications.
Inside of the [NSBlockOperation blockOperationWithBlock:^{ I create a child…

cynistersix
- 1,215
- 1
- 16
- 30
1
vote
0 answers
NSBlockOperations causing memory leaks, and causing deinit never gets called [swift]
var blockOperations = [NSBlockOperation]()
func controller(controller: NSFetchedResultsController, didChangeObject anObject: AnyObject, atIndexPath indexPath: NSIndexPath?, forChangeType type: NSFetchedResultsChangeType, newIndexPath: NSIndexPath?)…

slimboy
- 1,633
- 2
- 22
- 45
1
vote
1 answer
Swift NSBlockOperation() Leak: cannot make NSBlockOperation() weak
To avoid a memory leak when using NSBlockOperation in Objective-C, we would have to declare the variable as weak to be able to reference the block operation inside the block (to cancel if needed), typically like this:
__weak NSBlockOperation…

Jeshua Lacock
- 5,730
- 1
- 28
- 58
1
vote
1 answer
Changing @property value of self while executing a block that uses a strong reference to self
I'm working on doing network requests in my app and am using NSBlockOperations in an NSOperationQueue to do this asynchronously. However, I want to be able to cancel these operations if the view controller that called them is deallocated (has been…

Shawn Throop
- 1,281
- 1
- 13
- 28
1
vote
0 answers
Is NSBlockOperation serial?
We can keep adding block after block. Will those be executed serially?
I can't think of any reason why it's not. Nothing is specific.
This is not NSOperationQueue. This is NSBlockOperation that also can have several blocks

Septiadi Agus
- 1,775
- 3
- 17
- 26
1
vote
1 answer
Grouping NSOperation working on same object and detect when they have finished in iOS
I have an iOS app where 5 NSBlockOperation produce an NSArray of objects each and add it to a shared synchronized NSMutableArray which serves as a UITableView datasource.
The operation are independent from each other, and as soon as they have…

Leonardo
- 9,607
- 17
- 49
- 89
0
votes
1 answer
Asynchronously loading sound resources in viewDidLoad crashes
All,
I am attempting to load a set of sounds asynchronously when I load a UIViewController. At about the same time, I am (occasionally) also placing a UIView on the top of my ViewController's hierarchy to present a help overlay. When I do this, the…

DeepFriedTwinkie
- 3,865
- 1
- 21
- 21
0
votes
1 answer
Memory Leak NSBlockOperation
I declared NSBlockOperation with an object declared inside that operation. My app constantly is crashing because of memory issue. Appreciate any hint with a great explanation on this spent several hours still no success.
runtime: Memory Issues - (5…

Atalyk
- 495
- 1
- 5
- 11
0
votes
2 answers
why does __block not adding values to array
I am enumerating ranges inside a block and storing the values inside an array. I expected using __block should store the values inside block into array?
__block NSMutableArray *array;
[indexSet enumerateRangesUsingBlock:^(NSRange range,BOOL *…

humble_pie
- 119
- 10
0
votes
1 answer
iOS throttling async API calls using NSBlockOperation
I want to limit the number of inflight API calls to 2. I can create an NSOperationQueue and add the block to the queue, however each API call has a completion block, so the initial calls are limited but I don't know how to limit the processing of…

Magic Bullet Dave
- 9,006
- 10
- 51
- 81
0
votes
0 answers
NSBlockOperation retain cycle
I have to used NSOperations to download images (and save to disk), but memory didn't released! After some googling i found hook, that my operations in the retention cycle. I tried to fix my code, but problem is still here.
Can anyone find the error…

Nostromo
- 21
- 2
- 7