NSOperationQueue
NSOperationQueue
- Subject: NSOperationQueue
- From: John Love <email@hidden>
- Date: Sat, 13 Sep 2008 08:07:30 -0400
I have tried to create a Queue in which I have placed a rather lengthy
calculation. Without the Queue, my app is essentially “frozen” until
the calculation is completed.
I have attempted to put this long calculation in a Queue, but when I
try, my app literally crashes. So, here are some code snippets where I
obviously need your help:
@interface MyCalcController:NSObject {
NSString *opData;
NSOperationQueue *theQueue;
NSInvocationOperation *theOp;
}
- (void) startQueue;
- (void) stopQueue;
- (void) calculateWorksheet:(id)data;
- (void) startCalculation;
- (void) stopCalculation;
@end
- (void) calculateWorksheet:(id)data {
int row;
for (row=1; row < 500; row++) {
// very long calculation here
}
}
- (void) startQueue {
NSLog(@"start queue"); // I see this in the debugger
opData = @"not used data";
theQueue = [[NSOperationQueue alloc] init];
theOp = [[NSInvocationOperation alloc] initWithTarget:self
selector:@selector(calculateWorksheet:)
object:opData];
[theQueue addOperation:theOp];
}
- (void) stopQueue {
NSLog(@"stop queue"); // .. but I do not see this
[theQueue cancelAllOperations];
// [theQueue release]; // done by [theOp release];
[opData release];
[theOp release];
}
- (void) startCalculation {
[self startQueue];
}
// I also call this method from another Controller
- (void) stopCalculation {
[self stopQueue];
}
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden