大規模で複雑なオブジェクト グラフがあります。オブジェクト グラフをアーカイブおよびアーカイブ解除するために NSCoding を実装しました。通常、すべて正常に動作します。しかし、再現性の高い特定の状況下では、アーカイブした NSMutableDictionary が NSPlaceholderDictionary としてアーカイブ解除されます。これは NSMutableDictionary のプライベート サブクラスであり、初期化されていない辞書を表します。通常の NSDictionary メソッドには応答しません。
誰かが同様の問題に遭遇したかどうか疑問に思っています。もしそうなら、あなたはそれを解決できましたか?そしてどうやって?
編集:状況について言えることの1つは、辞書自体が深くネストされており、多くの辞書と配列が含まれていることです。その奥深くには、作成中の別のオブジェクトへのポインタがあります。オブジェクト グラフはツリーです。ツリー内のほとんどのオブジェクトには、親への弱い参照が含まれています。この問題は、ツリーの深さ n 層で発生します。クラッシュ時のスタックは次のようになります [簡略化しました]:
0. crash because dictionary is a placeholder
1. depth n initWithCoder -- decode a deep and large dictionary which, prior to encoding contained reference to object at depth n+4. Said object has not yet been decoded.
2. Apple methods
3. depth n+1 initWithCoder -- decode reference to parent
4. 38 frames of apple methods for very deeply nested dictionary
5. depth n-1 initWithCoder -- decode a deeply nested dictionary. Among other things, the dictionary contains a reference to the level n+1 object [inside a lot of nested dictionaries and arrays]
6. Apple methods
7. depth n-2 object initWithCoder -- decode reference to array containing its children