我有錯誤嘗試運行與核心數據的應用程序。 由於未捕獲的異常'NSInvalidArgumentException'而終止應用,原因:'對於多對多關係的值不可接受的類型:property =「ingredient」;期望的類型= NSSet;給定類型=成分;核心生成的訪問器沒有正確生成
我看到核心生成的訪問器addIngredient:和removeIngredient:都以NSSet作爲參數,因此我嘗試將其更改爲Ingredient,但這並沒有幫助。我懷疑,雖然我改變了頭文件中的參數,但是在實現中還有一些我看不到的東西?建議?
Recipe.h
@class IngredientList;
@interface Recipe : NSManagedObject
@property (nonatomic, retain) NSString * recipeName;
@property (nonatomic, retain) IngredientList *ingredientList;
@end
IngredientList.h
@class Ingredient, Recipe;
@interface IngredientList : NSManagedObject
@property (nonatomic, retain) Recipe *recipe;
@property (nonatomic, retain) NSSet *ingredient;
@end
@interface IngredientList (CoreDataGeneratedAccessors)
- (void)addIngredientObject:(Ingredient *)value;
- (void)removeIngredientObject:(Ingredient *)value;
- (void)addIngredient:(NSSet *)values;
- (void)removeIngredient:(NSSet *)values;
@end
Ingredient.h
@class IngredientList;
@interface Ingredient : NSManagedObject
@property (nonatomic, retain) NSString * ingredientName;
@property (nonatomic, retain) IngredientList *ingredientList;
@end
答案有幫助嗎?如果您需要更多信息,請與我們聯繫! –