0

当我从顶部菜单的编辑器中选择“创建 NSManagedObject 子类”时,我的代码会自动生成。

我想尝试使用两个功能,但我似乎无法访问它们。第一个是addToListsRel,另一个是removeFromListsRel

使用点表示法,它们似乎不可用,那么我如何使用这些?

import Foundation
import CoreData


extension Ent_Catalog {

    @nonobjc public class func fetchRequest() -> NSFetchRequest<Ent_Catalog> {
        return NSFetchRequest<Ent_Catalog>(entityName: "Ent_Catalog");
    }

    @NSManaged public var brand: String?
    @NSManaged public var id: Int32
    @NSManaged public var image: NSData?
    @NSManaged public var name: String?
    @NSManaged public var price: NSDecimalNumber?
    @NSManaged public var qty: NSDecimalNumber?
    @NSManaged public var size: String?
    @NSManaged public var itemsRel: Ent_Items?
    @NSManaged public var listsRel: NSSet?
    @NSManaged public var ingredientsRel: NSSet?
    @NSManaged public var sectionsRel: Ent_Sections?

}

// MARK: Generated accessors for listsRel
extension Ent_Catalog {

    @objc(addListsRelObject:)
    @NSManaged public func addToListsRel(_ value: Ent_Lists)

    @objc(removeListsRelObject:)
    @NSManaged public func removeFromListsRel(_ value: Ent_Lists)

    @objc(addListsRel:)
    @NSManaged public func addToListsRel(_ values: NSSet)

    @objc(removeListsRel:)
    @NSManaged public func removeFromListsRel(_ values: NSSet)

}

// MARK: Generated accessors for ingredientsRel
extension Ent_Catalog {

    @objc(addIngredientsRelObject:)
    @NSManaged public func addToIngredientsRel(_ value: Ent_Ingredients)

    @objc(removeIngredientsRelObject:)
    @NSManaged public func removeFromIngredientsRel(_ value: Ent_Ingredients)

    @objc(addIngredientsRel:)
    @NSManaged public func addToIngredientsRel(_ values: NSSet)

    @objc(removeIngredientsRel:)
    @NSManaged public func removeFromIngredientsRel(_ values: NSSet)

}
4

1 回答 1

0

我认为点符号看起来像Catalog.listsRel.addToListsRel. 原来它实际上Catalog.addToListsRel

希望这对其他人有帮助。

于 2017-03-13T18:13:31.203 回答