1) вам следует избегать повторного объявления реализованного интерфейса подкласса для ваших дополнений (например, -[NSOperation isCancelled]
существует)
2) очень необычно начинать с двух оставшихся отсчетов:
database = [[MySQLIXC alloc] initWithQuene:iQuene andCarrier:startForCarrier withState:cancelled];
[otherThingThatHoldsAReference setDatabase:database];
вместо:
database = [[[MySQLIXC alloc] initWithQuene:iQuene andCarrier:startForCarrier withState:cancelled] retain];
3) _currentQueueStatus
- это не null
, это BOOL
, то есть signed char
. должно быть 0
(NO
) или 1
(YES
).
4) что такое currentQueueStatus
? больше кода поможет вам получить более конкретные ответы.
РЕДАКТИРОВАТЬ: обновлено для уточнения в ответ на комментарии
/* things would look different if you subclass MONOperation */
@interface MONOperation : NSOperation
{
@private
MySQLIXC * sqlIxc;
BOOL didCancelDatabaseRequest;
}
/*
do not use isCancelled for your name - NSOperation declares this method, and
its implementation is well defined. this would override the implementation
and likely cause runtime errors.
specifically, NSOperation/NSOperationQueue uses cancel and isCancelled in its
interface and state. if you must cancel, then call cancel from cancelDatabaseRequest.
you may override cancel, but call [super cancel] in your implementation.
*/
@property (readonly) BOOL didCancelDatabaseRequest;
@property (retain) MySQLIXC * sqlIxc;
@end
@implementation MONOperation
/* ... */
- (BOOL)didCancelDatabaseRequest
{
return didCancelDatabaseRequest;
}
- (void)cancelDatabaseRequest /* in this example, there is no sense making cancelDatabaseRequest publicly visible */
{
/* for example */
assert(self.sqlIxc);
self.sqlIxc = nil;
didCancelDatabaseRequest = YES;
[self cancel]; /* do this rather than overriding NSOperation's cancellation interfaces in your subclass */
}
- (void)main
{
NSAutoreleasePool * pool = [NSAutoreleasePool new];
assert(self.sqlIxc);
self.sqlIxc.doStuff;
if (self.sqlIxc.didTimeout || self.sqlIxc.couldNotAccessFile) {
[self cancelDatabaseRequest];
}
else {
/* use the result */
}
[pool release];
}
@end