セーブオンapplicationWillTerminate
とロードオンを実装しましたapplicationWillFinishLoading
。完全なオブジェクト ツリーがあり、すべてがNSCoding
プロトコルを実装しており、入力した型を確認しました。
クラスの 1 つには to も保存NSMutableData
されていNSKeyedArchive
ます。奇妙なことに、うまくいくこともあれば、うまくいかないこともあります。NSMutableData
の一部のコンテンツがアーカイブを壊すと思われます。
正しい対応するメソッドを使用する bools と int を除いて、すべてのオブジェクトで encodeObject を使用します (encodeBool:forKey:
およびencodeInt:forKey:
)
より明確にするために、コードは実際に機能します。常にではなく、かなり完全なオブジェクトグラフを再構築できる場合があります。
私が得るエラーメッセージは次のとおりです。
initForReadingWithData incomprehensible archive 0x62, 0x70, 0x6c, 0x69, 0x73, 0x74, 0x30, 0x30
追加: 失敗しているコードNSMutableData
、10 MB 以上のコード
- (void)encodeWithCoder:(NSCoder*)encoder {
[encoder encodeObject:self.encodedMessage forKey:@"EncodedMessage"]; //NSData
[encoder encodeObject:self.data forKey:@"Data"]; //NSMutableData (10+MB)
[encoder encodeObject:self.header forKey:@"Header"]; //NSString
[encoder encodeObject:self.fileName forKey:@"FileName"]; //NSString
[encoder encodeInt:self.dataStartIndex forKey:@"DataStartIndex"]; //int
[encoder encodeInt:self.dataEndIndex forKey:@"DataEndIndex"]; //int
}
- (id)initWithCoder:(NSCoder*)decoder {
if (self = [super init]) {
self.encodedMessage = [decoder decodeObjectForKey:@"EncodedMessage"]; //NSData
self.data = [decoder decodeObjectForKey:@"Data"]; //NSMutableData
self.header = [decoder decodeObjectForKey:@"Header"]; //NSString
self.fileName = [decoder decodeObjectForKey:@"FileName"]; //NSString
self.dataStartIndex = [decoder decodeIntForKey:@"DataStartIndex"]; //int
self.dataEndIndex = [decoder decodeIntForKey:@"DataEndIndex"]; //int
}
return self;
}
self.data のエンコードとデコードを削除すると、常に機能しているように見えます。小さいサイズの self.data でも失敗します。サイズじゃなくて中身の問題?
nsmutabledata を書き込んだときにファイルを開こうとすると、適切なリスト エディターに次のエラーが表示されます。
"Conversion of string failed. The string is empty."
plutil も次のエラーを返します。
"$ plutil -lint nzbvortex.state nzbvortex.state: Conversion of string failed. The string is empty."