osx - What issues could arise when using GCD dispatchAfter() in this use case -
i'm going through book on os x programing refresher , have document app set array controller, tableview etc. chapter calls implementing undo support hand using nsinvocation. in chapter, call adding create employee method , manually, adding outlets nsarraycontroller, , connecting add button new method instead of array controller.
instead did method inserting new objects:
-(void)insertobject:(person *)object inemployeesatindex:(nsuinteger)index { nsundomanager* undomanager = [self undomanager]; [[undomanager preparewithinvocationtarget:self]removeobjectfromemployeesatindex:index]; if (![undomanager isundoing]) { [undomanager setactionname:@"add person"]; } [self startobservingperson:object]; [[self employees]insertobject:object atindex:index]; dispatch_after(dispatch_time(dispatch_time_now, (int64_t)(.1 * nsec_per_sec)), dispatch_get_main_queue(), ^{ // wait start editing [[self tableview]editcolumn:0 row:index withevent:nil select:yes]; });
}
this works ok (looks bit silly), wondering issues arise this. i've done elsewhere in order execute code after animation finished (couldn't figure out better way).
thanks in advance.
why delaying invocation of -editcolumn:row:withevent:select:
?
anyway, risks else done between end of -insertobject:...
method , when dispatched task executes. perhaps change contents of table view such index
no longer refers just-added employee.
Comments
Post a Comment