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
3 answers

What would be the equivalent of doing this with NSOperation?

[self performSelector:@selector(stopPulling) withObject:nil afterDelay:0.01]; The code is fine. I just think that using NSOperation and block should be the way to go for the future. I am familiar with NSOperation. I just want to do the same thing…
Anonymous White
  • 2,149
  • 3
  • 20
  • 27
0
votes
1 answer

NSOperation suspended after sleep mode

I am using S3uploader OSx sdk (I modified the IOS sdk) for uploading files in my app. For what ever files (one file or a chunk of files) I upload, am creating an NSOperation. This operation will invoke the S3uploader sdk to upload the files. It's…
Advaith
  • 1,087
  • 3
  • 12
  • 31
0
votes
2 answers

Issue with setImageWithURL AFNetworking success handler

Neither the success or failure handler appears to be called when setImageWithURLRequest: is called on my UIImage object. SetImageWithURL does not set my image either. If I use setImageWithURL: placeholder: the placeholder is set but the image from…
davetw12
  • 1,815
  • 2
  • 20
  • 27
0
votes
1 answer

How to tell how long a NSOperation has been executing?

Is there a way to tell how long a NSOperation has been executing? for (NSOperation *operation in [self.operationQueue operations]) { // how to tell how long the operation has been executing? }
ohho
  • 50,879
  • 75
  • 256
  • 383
0
votes
1 answer

NSOperation never gets deallocated

I have objects that extends NSOperation. I also have NSOperationQueue. I have a timer that NSLogs operationCount property of that NSOperationQueue every 0.5 seconds. I add new operations to queue and after all of them are finished, queue logs 0 just…
vale4674
  • 4,161
  • 13
  • 47
  • 72
0
votes
1 answer

How to wake up thread after [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:distantFuture]?

I have a Download object which handles NSURLConnection. Then I have NSOperation object (DownloadOperation) which holds Download object as property. Download object has ability to start/pause/resume/cancel. This is the main method of…
vale4674
  • 4,161
  • 13
  • 47
  • 72
0
votes
4 answers

EXC_BAD_ACCESS when adding NSOperation to NSOperationQueue

I've been sitting on this error for hours now. I'm getting an EXC_BAD_ACCESS (code=2) on the line: [self.downloadQueue addOperation:self.downloadOP]; I know it has to be related to memory conflicts, but I just can't find the problem. The class that…
Chris
  • 489
  • 5
  • 15
0
votes
0 answers

Properties not changing on NSOperation

I have an NSOperation running on a background thread, and I want to change a property of it, a float named runSpeed, upon getting a memory warning on the main thread. The next time the background thread hits runSpeed though, it appears to be the…
Andrew
  • 15,935
  • 28
  • 121
  • 203
0
votes
0 answers

NSOperation not continuing after "attributesOfItemAtPath:error " method

I have an NSOperation and am inserting the operation into an operationqueue. I need to set the max concurrent operations to 1. I'll be inserting many such operations from time to time. But I need atmost one operation to be executed at a time. At…
Advaith
  • 1,087
  • 3
  • 12
  • 31
0
votes
1 answer

AFNetworking - operation time issue

I'am foolin around with AFNetworking, and I need help. I want a UIView to appears (Scroll up) when I make an operation request, and when the operation is done the UIView disappers (Scroll down). - simpel animation. :) My scroll up time is 1 sec. and…
Morten Gustafsson
  • 1,869
  • 2
  • 24
  • 34
0
votes
2 answers

NSOperaionQueue and UIAlertView

The problem is that if I create and display two alert - the second will override the first, and after it closed displayed first. So not pretty. I'm trying to create a queue alerts with NSOperationQueue. That you could add a few alerts and they show…
glebus
  • 197
  • 1
  • 1
  • 11
0
votes
2 answers

How to use NSURLConnection inside a dispatch_queue or NSThread or NSOperationQueue?

I have tried using NSURLConnection inside NSThread and dispatch_queue. The implemented NSURLConnectionDelegate methods are not called. But when I used NSOperation inside of NSThread and NSOperationQueue, the methods are called.
0
votes
1 answer

I need informations about the thread in a NSOperation in concurrency mode

I have a NSURLConnection asynchrone in NSOperation in concurrency mode. I know that by default, the NSOperationQueue creates the thread for the NSOperation (non-concurrent). But, in concurrency, does it means that i have one thread in another…
0
votes
1 answer

Use of NSOperation in upload HTTP code

I need to implement a subclass of NSOperation which does a file upload to a HTTP server and with an option that the user can cancel the file upload during operation. Here is the code at the moment: NSArray *paths =…
berlos
  • 1
0
votes
2 answers

NSOperationQueue operations filteredArrayUsingPredicate error

I have class MyOperation : NSOperation with @property (nonatomic, retain) NSString *oID; And sometimes I need to cancel operation with specific oID. I'm trying to do this: NSArray *operations = operationQueue.operations; NSPredicate *predicate =…
Rost K.
  • 262
  • 2
  • 14