So I have been working for the past couple of weeks trying to use relationships in order to have an array of object ingredient
to an individual class of recipe
. I've been watching this video. Now, By creating two extensions of recipe
and ingredient
classes, I'm getting a ton of errors all in my code, specifically saying
invalid use of (class structure)
or
ambiguous use of (class structure)
I have a Git Repo on GitHub that you can diagnose my code here if that is preferable.
If not, here are the extensions that I've made
Recipe Class:
import Foundation
import CoreData
extension Recipe {
@nonobjc public class func fetchRequest() -> NSFetchRequest<Recipe> {
return NSFetchRequest<Recipe>(entityName: "Recipe")
}
@NSManaged public var ingredients: String?
@NSManaged public var instructions: String?
@NSManaged public var time: String?
@NSManaged public var title: String?
@NSManaged public var ingredient: [Ingredient]?
}
// MARK: Generated accessors for ingredient
extension Recipe {
@objc(addIngredientObject:)
@NSManaged public func addToIngredient(_ value: Ingredient)
@objc(removeIngredientObject:)
@NSManaged public func removeFromIngredient(_ value: Ingredient)
@objc(addIngredient:)
@NSManaged public func addToIngredient(_ values: NSSet)
@objc(removeIngredient:)
@NSManaged public func removeFromIngredient(_ values: NSSet)
}
And the ingredient class:
import Foundation
import CoreData
extension Ingredient {
@nonobjc public class func fetchRequest() -> NSFetchRequest<Ingredient>{
return NSFetchRequest<Ingredient>(entityName: "Ingredient")
}
@NSManaged public var cost: Double
@NSManaged public var name: String?
@NSManaged public var unit: String?
@NSManaged public var recipe: NSSet?
}
// MARK: Generated accessors for recipe
extension Ingredient {
@objc(addRecipeObject:)
@NSManaged public func addToRecipe(_ value: Recipe)
@objc(removeRecipeObject:)
@NSManaged public func removeFromRecipe(_ value: Recipe)
@objc(addRecipe:)
@NSManaged public func addToRecipe(_ values: NSSet)
@objc(removeRecipe:)
@NSManaged public func removeFromRecipe(_ values: NSSet)
}