为什么我收到“不支持归档”在我的 NSWindow 子类中?
我有以下课程:
@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协议,所以我不知道为什么会看到这个问题。
有什么想法吗?
--- 编辑: NSWindow 的类参考显示:
Conforms to NSCoding (NSResponder)
... NOT 只是 “符合 NSCoding”
- 所以我猜这是否意味着只有 NSResponder 位符合 NSCoding 吗?
I have the following class:
@interface SpWindow : NSWindow <NSCoding> {
BOOL _editMode;
SpBgView *bgView;
} ...
... which I then call archive on. My encode method is as follows:
- (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"];
}
... however the [super encodeWithCoder:aCoder];
bit results in the following in the console log:
encodeWithCoder CALLED FOR SpWindow
<SpWindow: 0x20009f660> does not support archiving
*** -[NSKeyedArchiver finalize]: warning: NSKeyedArchiver finalized without having had -finishEncoding called on it.
... according to the NSWindow documentation the class conforms to the NSCoding protocol, so I have no idea why I'm seeing this issue.
Any ideas ?
--- EDIT: The class reference for NSWindow shows:
Conforms to NSCoding (NSResponder)
... NOT just "Conforms to NSCoding"
- so I guess does this mean that only the NSResponder bits conform to NSCoding ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
直接来自 NSWindow 文档:
Straight from the NSWindow documentation:
你的类实现了整个协议还是仅仅实现了encodeWithCoder?标记为“必需”的方法不是可选的。
Does your class implement the entire protocol or just encodeWithCoder? Methods marked "required" are not optional.
好吧,看起来我是我干预 MVC 模型的受害者 - NSview & NSWindow 不做 NSCoding 的事情。
OK, it looks like I'm a victim of my meddling with the MVC-model - NSview & NSWindow don't do the NSCoding thing.