I use NSProgress to notify about progress of a complicated task (the task consist of many subtasks, that can consist of other subtasks).
I create main progress in startTask method:
- (void)_startTask
{
_progress = [NSProgress progressWithTotalUnitCount:100]; //sometimes crash is here
<...>
}
There is no currentProgress:
(lldb) po [NSProgress currentProgress]
nil
Sometimes I get crash with strange stackTrace:
0: 0x000000018539a7e8 in object_isClass ()
1: 0x0000000186b39fe0 in KVO_IS_RETAINING_ALL_OBSERVERS_OF_THIS_OBJECT_IF_IT_CRASHES_AN_OBSERVER_WAS_OVERRELEASED_OR_SMASHED ()
2: 0x0000000186b384bc in
NSKeyValueWillChangeWithPerThreadPendingNotifications ()
3: 0x0000000186cac9c0 in -[NSProgress _setValueForKeys:settingBlock:] ()
4: 0x0000000186cacc7c in -[NSProgress setTotalUnitCount:] ()
5: 0x0000000186cab718 in +[NSProgress progressWithTotalUnitCount:] ()
This code executes in mainThread.
Why does this happens and what I can do to avoid this?