ios - Cancelled NSOperation EXC_BAD_ACCESS crash when setting isFinished -
i have nsoperation
subclass runs async operations uitableview
.
i override correct start , finish methods this:
- (void)start { [self willchangevalueforkey:@"isexecuting"]; self.isexecuting = yes; [self didchangevalueforkey:@"isexecuting"]; if (self.iscancelled) { [self finish]; return; } } - (void)finish { if (!_isexecuting) { [self willchangevalueforkey:@"isexecuting"]; _isexecuting = yes; [self didchangevalueforkey:@"isexecuting"]; } [self willchangevalueforkey:@"isexecuting"]; [self willchangevalueforkey:@"isfinished"]; _isexecuting = no; _isfinished = yes; [self didchangevalueforkey:@"isexecuting"]; [self didchangevalueforkey:@"isfinished"]; }
the problem have, if scroll down table , delete row, calls cancel
method on operation, operations gradually complete , reaches further down table, crashes exc_bad_access
error on line [self didchangevalueforkey:@"isfinished"];
the code pretty complex paste here, i'd know how can track down object causing kvo message crash?
if enable zombie objects in debugger, doesn't crash @ no warnings doesn't help.
if wrap kvo methods in try/catch
never caught , still crashes.
i have tried overriding kvo methods in nsoperation
subclass, never called:
- (void)addobserver:(nsobject *)observer forkeypath:(nsstring *)keypath options:(nskeyvalueobservingoptions)options context:(void *)context { nslog(@"%s - %@", __pretty_function__, observer); [super addobserver:observer forkeypath:keypath options:options context:context]; }
is possible see observers are?
comments , ideas:
- in
start
shouldn'tself.isexecuting = yes
_isexecuting = yes;
? - add property called
identifier
of type nsstring, , set each op. - add
dealloc
method , logidentifier
. - in
finish
testiscancelled
, return if so.
another thought doubly retain operations - put them in nsdictionary identifier
key, , see if changes.
Comments
Post a Comment