Questions tagged [nsoperation]

The NSOperation class is an abstract class you use to encapsulate the code and data associated with a single task

The NSOperation class is an abstract class you use to encapsulate the code and data associated with a single task. Because it is abstract, you do not use this class directly but instead subclass or use one of the system-defined subclasses (NSInvocationOperation or NSBlockOperation) to perform the actual task. Despite being abstract, the base implementation of NSOperation does include significant logic to coordinate the safe execution of your task. The presence of this built-in logic allows you to focus on the actual implementation of your task, rather than on the glue code needed to ensure it works correctly with other system objects.

An operation object is a single-shot object—that is, it executes its task once and cannot be used to execute it again. You typically execute operations by adding them to an operation queue (an instance of the NSOperationQueue class). An operation queue executes its operations either directly, by running them on secondary threads, or indirectly using the libdispatch library (also known as Grand Central Dispatch). For more information about how queues execute operations, see NSOperationQueue Class Reference.

If you do not want to use an operation queue, you can execute an operation yourself by calling its start method directly from your code. Executing operations manually does put more of a burden on your code, because starting an operation that is not in the ready state triggers an exception. The isReady method reports on the operation’s readiness.

http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/NSOperation_class/Reference/Reference.html

983 questions
0
votes
1 answer

NSOperationQueue waitUntillAllOperationsAreFinished blocks operations

I've created my own NSOperation subclass and now I want some of its instances to run in parallel. As it's a concurrent operation I've overwritten - (void)start { [self willChangeValueForKey:@"isExecuting"]; isExecuting = YES; [self…
Nickkk
  • 2,261
  • 1
  • 25
  • 34
0
votes
1 answer

NSOperation that will operate on UIView launches before layoutSubviews is called

Say I have a subclass of UIView which I will call AnimatableView, where my implementation of layoutSubviews lays out some internal content. AnimatableView also has the method commenceAnimationLoop which looks something like this: - (void)…
Barjavel
  • 1,626
  • 3
  • 19
  • 31
0
votes
2 answers

NSOperation subclass not calling delegate methods and NSOperationQueue not waiting until finished

I use this piece of code to create some NSOperations and add them to a queue: HUD = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES]; //HUD.labelText = @"Downloading.."; //HUD.dimBackground = YES; …
Jack Nutkins
  • 1,555
  • 5
  • 36
  • 71
0
votes
1 answer

Use NSXMLParser and NSOperation without block UI

i have a search bar and search some information from internet, then start a NSXMLParser from url and then show information parsed in a UITableView, but in this process the UI is blocked, and if i want to cancel the searching to do another search i…
Piero
  • 9,173
  • 18
  • 90
  • 160
0
votes
1 answer

How can i set the priority in NSOperationQueue to execute the next operation until the previous is finished?

How can i set the priority in NSOperationQueue to not execute the next operation until the previous operation is finished? NSOperationQueue *operationQueue = [[NSOperationQueue alloc] init]; [operationQueue setMaxConcurrentOperationCount:1]; …
Ziad.T
  • 119
  • 4
0
votes
1 answer

a bunch of requests with gcd

So the task is the following: 1)I have a track ID, I need to ask the server for all the track data 2)parse response (here I also have an album ID) 3)now I have an album ID, I need to ask the server for all the album data 4)parse response (here I…
dariaa
  • 6,285
  • 4
  • 42
  • 58
-1
votes
1 answer

Calling -[NSRunLoop runMode:beforeDate:] on main thread causes queued NSOperations to run on main thread

I ran into an issue today where my app was failing to start in time. It turns out some third-party code I was using was trying to get the user agent string using the trick below: -(NSString*)userAgentString { webView = [[UIWebView alloc] init]; …
Carl Veazey
  • 18,392
  • 8
  • 66
  • 81
-1
votes
1 answer

ASIHTTPRequest as instance variable and deallocating and releasing

"Informazioni.h file" @interface Informazioni : UIViewController{ ..... ASIHTTRequest *mASIHTTPRequest; } @property (nonatomic, retain) ASIHTTRequest *mASIHTTPRequest; ---------------------------- #import "Informazioni.h" #import…
user966337
  • 11
  • 3
-1
votes
1 answer

Why does my BlockOperation continue after I add it to an OperationQueue?

Apple documentation says that Operations run synchronously. Why then does the code continue to run after an operation is added to a queue? Here is my code: let op = BlockOperation(block: { print("Done") }) let qu =…
daniel
  • 1,446
  • 3
  • 29
  • 65
-1
votes
1 answer

Replace asynchronous requests with synchronous requests in background thread in iOS?

I tried AFHTTPRequestOperation objects combined with other NSOperation objects placed into a queue. But now I know that in AFHTTPRequestOperation only requests are performed in correct order (not response processing blocks). I don't need the correct…
Gargo
  • 1,135
  • 1
  • 10
  • 21
-1
votes
1 answer

I want to continue to process image and store it when iOS App in background

I tried to use NSOperation and NSOperationQueue. But As getting into background, NSOperation didn't work. it stopped. Calling - (void)viewDidLoad { findFQueue = [[NSOperationQueue alloc] init]; FindFeatureOperation *testOperation =…
nao0811ta
  • 183
  • 4
  • 11
-1
votes
1 answer

Using blocks in NSOperation main method

I'm using blocks inside a NSOperation. The main method of my NSOperation looks like this: - (void) main { [self callMethodOfALiraryUsingCompletionBlock:^() { //this method takes time to execute, will call this block when done …
rmonjo
  • 2,675
  • 5
  • 30
  • 37
-1
votes
1 answer

Loading 50 UITableviews on a Screen Asynchronously

Like the question said. I tried NSOperationQueues but I am confused as to what to execute in the operation block. I tried the function reloadData to load in the operation queue but all the UITableViews appear at once. I am using custom cells on…
Anton Unt
  • 1,835
  • 1
  • 21
  • 47
-1
votes
2 answers

iOS correct use of multithreading

I would like to know how to use multithreading in iOS. I am aware of GCD and NSOperationQueue, but I am not sure how to use them properly. When should I use GCD/NSOperationQueue? How do I cancel a queue if the view for the results are no longer in…
-1
votes
1 answer

How to use NSOperation and dispatch queue

I am using NSoperation in Initiating request to server.Pullparser will be called and it will initiate a o/p & i/p stream.In connecitonDidRecievedata I am writing data coming from server to oStream.Imeediately I have to call custom method instead of…
1 2 3
65
66