NSOperationQueue
NSOperationQueue
- Subject: NSOperationQueue
- From: John Love <email@hidden>
- Date: Sat, 13 Sep 2008 08:05:50 -0400
I have tried to create a Queue in which I place a long calculation.
Without the Queue, my app is “frozen” until the calculation is complete.
However, my app literally crashes. So, here are some 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++) {
// 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];
}
John Love
Touch the Future! Teach!
_______________________________________________
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