Hi
I am using a subclass of NSOperation to do some background processes. I want the operation to be cancelled when the user clicks a button.
Here's what my NSOperation subclass looks like
- (id)init{
self = [super init];
if(self){
//initialization code goes here
_isFinished = NO;
_isExecuting = NO;
}
re...
I have a NSOperation that downloads some data using NSURLConnection, it looks somewhat like this:
....
- (void)main
{
....
while (!self.isCancelled && !self.isLoaded)
{
[NSRunloop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NDate distantFutute]];
}
....
}
The problem is that from time to time connection han...
Hi there,
I'm having a lot of issues with trying to perform some core data operations in a threaded NSOperation.
Currently, I have created a managed object context in my app delegate that is purely used on my threaded NSOperations. I setup a NSOperationQueue with a max concurrency of 1 so each action is performed serially. For each ope...
I have been living on Instruments for last few hours staring at a puzzling memory leak. I have isolated it to this single line of code in an NSOperation subclass I wrote:
NSData *myData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:myURLString]];
Periodically this will leak 3500 bytes. Is anyone else seeing this? If so,...
I have an NSOperationQueue on my main thread running a set of NSOperations (max concurrent set to 1) that I want to be able to cancel at any time. When I press a button I tell the queue to cancel all operations and wait until finished. This should hang the main thread until the operation queue is empty, however it is hanging my main thre...
I have an NSOperation. When it is finished I fire a NSNotificationCenter to let the program know that the NSoperation is finished and to update the gui.
To my understanding listeners to the NSNotification will not run on the main thread because the NSOperation is not on the main thread.
How can I make it so that the listeners run on...
I'm trying to use NSAssert throughout my iPhone app so that if an unexpected condition occurs, the application fails-fast and crashes with a meaningful message in the crash log.
This works fine if the failing NSAssert is on the main thread, as it raises NSInternalInconsistencyException by default which is uncaught and stops execution. B...
Consider this:
@interface SomeViewController : UIViewController {
SomeChildObject *child;
}
@end
@implementation SomeViewController
- (void) viewDidLoad {
...
child.delegate = self;
}
- (void) somethingHappened {
NSInvocationOperation *operation = [[NSInvocationOperation alloc]
initWithTarget:child
sel...
Hi,
I'm after some advice on the use of NSOperation and drawing:
I have a main thread create my NSOperation subclass, which then adds it to an NSOperationQueue.
My NSOperation does some heavy processing, it is intended to loop in its main() method for several minutes, constantly processing some work, but for now I just have a while() ...
Hi,
Hope you guys can help me :)
In the main thread, I create a NSOperation and add it to a queue.
What that operation do is connect to a data server with NSURLConnection, save the receivedData and parse it.
Operation.m
- (void)start
{
NSLog(@"opeartion for <%@> started.", [cmd description]);
[self willChangeValueForKey:@"i...
Hey I have been battling with this problem for a while now. Perhaps there is something I am missing in knowledge about multi threading but here is what happens. When I create an nsoperation queue any variables that are allocated become cleared after the "[request startSynchronous];" line of code. Here is what I'm talking about:
@impleme...
Steps,
Crate window application with single form
add new datasource from Data->Add new Data source
Goto Data->Show Data Source
Drop any table to form. This step will add tow controls. a. DataGridView b. Binding Navigator
press F5 to run.
I am able to view all the records but not able to do add/update/delete.
Below is the code of t...
Hi I got some problem with NSOperation .
I always got error at "self = [super init];" (already use break point to find this)
it always return "Program recieved signal: EXC_BAD_ACCESS" all the time
//AddThread.h
@interface AddThread : NSOperation
{
NSString * str;
}
@property (nonatomic,retain) NSString * str;
-(id) ...
My app has an NSOperation class called ServerRequest that handles networking tasks. According to instruments, it is leaking like crazy. Additionally, instruments says the code that builds the request is leaking, even though that is not an NSOperation. But I have followed Apple's advice in terms of setting up an autorelease pool, so I ...
Hello Gentlebeings,
I have a weird issue. Here is the setup:
I have a NSOperationQueue which I add NSOperation subclass objects to. These do networking using NSURLConnection sendSynchronousRequest method. As I understand it, these are completely asynchronous, since they are NSOperations which each get their own thread.
If I launch my ...
Hi,
I am having problem with this code.Basically I want to execute the fwrite from a timer function asyncronusly.
Here is the code block in my Timer function. (This will call by the timer every 0.2 seconds.
-(void)timerFunction
{
WriteFileOperation * operation =
[WriteFileOperation writeFileWithBuffer:pFile buffer:readb...
Update
I wrote a minimal code example of the issue I am having. I implemented the background work two ways: manually spawning threads and letting NSOperation handle threading. In both cases I am creating NSManagedObjectContexts for each thread/operation.
When I spawn the threads myself with performSelectorInBackground:withObject: eve...
I am creating an application which involves so many web-service calls. I am using NSOperation to execute the web-service calls. There are several views in the application and I'm calling the web-service each time the view loads.
Since it is navigation, if user decides to go back to the previous view even before the operation gets complet...
Hello i am using NSOperationQueue to download images in the background. I have created a custom NSOperation to download the images. I put the images in table cells. The problem is if I do [operationQueue setMaxConcurrentOperationCount: 10] and i scroll down several cells the program crashes with EXC_BAD_ACCESS. Every time it crashes at t...
Hello!
I would like to use NSOperations in my application to resolve threading problems. I have read some tutorials and now I know what I have to do, but I have a problem. There is a must to have the same NSOperationQueue in each class. What if I use a new NSOperationQueue in each class. There will be concurrency problems?
...