gpt4 book ai didi

cocoa - 为什么我的 NSWindow 子类中出现 "does not support archiving"?

转载 作者:行者123 更新时间:2023-12-03 16:56:09 28 4
gpt4 key购买 nike

我有以下类(class):

@interface SpWindow : NSWindow <NSCoding> {
BOOL _editMode;
SpBgView *bgView;
} ...

...然后我将其称为存档。我的编码方法如下:

- (void) encodeWithCoder:(NSCoder *)aCoder {
NSLog(@"encodeWithCoder CALLED FOR SpWindow");
[super encodeWithCoder:aCoder];
NSLog(@"SpWindow's encodeWithCoder got past the super call");
[aCoder encodeObject:bgView forKey:@"bgView"];
[aCoder encodeBool:_editMode forKey:@"_editMode"];
}

...但是 [superencodeWithCoder:aCoder]; 位会在控制台日志中产生以下结果:

encodeWithCoder CALLED FOR SpWindow
<SpWindow: 0x20009f660> does not support archiving
*** -[NSKeyedArchiver finalize]: warning: NSKeyedArchiver finalized without having had -finishEncoding called on it.

...根据 NSWindow 文档,该类符合 NSCoding 协议(protocol),所以我不知道为什么会看到这个问题。

有什么想法吗?

--- 编辑: NSWindow 的类引用显示:

Conforms to NSCoding (NSResponder)

...只是“符合 NSCoding” - 所以我猜这是否意味着只有 NSResponder 位符合 NSCoding?

最佳答案

直接来自 NSWindow 文档:

Note: Although the NSWindow class inherits the NSCoding protocol from NSResponder, the class does not support coding. Legacy support for archivers exists but its use is deprecated and may not work. Any attempt to archive or unarchive an NSWindow object using a keyed coding object raises an NSInvalidArgumentException exception.

关于cocoa - 为什么我的 NSWindow 子类中出现 "does not support archiving"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1917268/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com