1

我收到错误

显式声明 getter '-newRelationship' 和 ' attribute ((objc_method_family(none)))' 以返回一个 'unowned' 对象

尝试访问此属性时

@property (nonatomic, strong) NSString* newBornTypeRawValue;

在子类的扩展中。我正在使用 coreData 和 mogenerator。超类是用 mogenerator 生成的,然后在子类的快速扩展中我有以下代码

extension SubClassName {
    var newBornType: DifferentType? { 
        get {
            willAccessValue(forKey: "newBornTypeRawValue")
            let storedStringOP = primitiveNewBornTypeRawValue()
            didAccessValue(forKey: "newBornTypeRawValue")

            if let storedString = storedStringOP {
                return DifferentType(storedString)
            } else {
                return nil
            }
        }

        set {

            guard let newValue = newValue else {
                willAccessValue(forKey: "newBornTypeRawValue")
                setPrimitiveNewBornTypeRawValue(nil) 
                self.didAccessValue(forKey: "newBornTypeRawValue")
                return
            }

            let rawValue = newValue.rawValue //This returns a String

            willAccessValue(forKey: "newBornTypeRawValue")
            setPrimitiveNewBornTypeRawValue(rawValue)
            didAccessValue(forKey: "newBornTypeRawValue")

        }
    }
}
4

0 回答 0