gpt4 book ai didi

ios - swift NSKeyedArchiver : Do custom members of an NSCoding-conformant class need to conform to NSCoding as well?

转载 作者:行者123 更新时间:2023-11-30 11:14:48 27 4
gpt4 key购买 nike

假设我有这个 Swift 类:

class Foo: NSObject, NSCoding
{
var stringMember: String
var intMember: Int
var customObjectMember: CustomObject
//conforms with encode and required init...
}

我知道“Foo”必须符合 NSCoding,这样我才能存档它。成员“customObject”是否也必须符合 NSCoding/NSObject 还是可以是常规 Swift 类?

最佳答案

答案是"is"。自定义对象成员也必须符合 NSCoding。

关于ios - swift NSKeyedArchiver : Do custom members of an NSCoding-conformant class need to conform to NSCoding as well?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51849609/

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