私は、基本的な整数値であるいくつかの "var"と、プリミティブな整数値の配列またはCMTimeのような構造体の配列を持つSwiftクラスを持っています。オブジェクト上でNSKeyedArchiver.archiveRootObjectを実行すると、エンコードを整数値[CMTime]と整数配列の最小値に制限すると、すべて正常に動作します。 (私はエンコードし、デコードし、コンテンツの平等性を確認することができます) 困惑していることは、デバッガが理解している[UInt16]エンコーディングが100M未満のメンバーで、エンコーディング中にアプリケーションのメモリ割り当てが4Gb 、次に8Gb、次に12Gb(ここで私はSTOPに当たった)。 私はcoder.encode(aSwiftArray、forKey: "aKey")の使用に問題がありますか?私のSwift 3エンコードが逃げるのはなぜですか?
typealias WordSize = UInt16
class PixelHistogram :NSObject, NSCoding {
var pixelCount:Int = 0
var timeAtFrame: [CMTime] = [] // CMTime for each frame
var pixelVsDelta: [UInt] = [] // 256x256 histogram of pixel vs DeltaPixel
var histPixel:[WordSize] = [] // histogram of Y at each pixel [pixelCount][256]
}
// Initializing the various arrays...
histPixel = [WordSize](repeating: 0, count: 256*pixelCount)
pixelVsDelta = [UInt](repeating: 0, count: 256*256)
required convenience init?(coder aDecoder:NSCoder){
self.init()
timeAtFrame = aDecoder.decodeObject(forKey:Slot.timeAtFrame.rawValue) as! [CMTime]
pixelVsDelta = aDecoder.decodeObject(forKey:Slot.pixelVsDelta.rawValue) as! [UInt]
func encode(with coder:NSCoder)
coder.encode(timeAtFrame, forKey: Slot.timeAtFrame.rawValue)
coder.encode(pixelVsDelta, forKey: Slot.pixelVsDelta.rawValue)
}
あなたの質問を関連コードで編集してください。 – rmaddy
必要に応じてコードをアップロードして関連サンプルを表示する –