使用'__attribute __((objc_method_family(none)))'明确声明getter'-newRelationship'以返回'unowned'对象生成器

时间:2017-04-07 05:16:00

标签: ios objective-c swift core-data mogenerator

我收到了错误

  

明确声明getter'-newRelationship'   '属性((objc_method_family(none)))'返回'无主'   对象

尝试访问此属性时

@property (nonatomic, strong) NSString* newBornTypeRawValue;

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

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")

        }
    }
}

0 个答案:

没有答案