我有問題與核心數據 - 節能關係到現有的對象(的UserData)。我想幾個位置保存到一個用戶 - 關係是(用戶)到很多(位置)創建現有對象的關係在覈心數據
這是的UserData:
@class ApiKey, Positions, SecretApiKey;
@interface UserData : NSManagedObject
@property (nonatomic, retain) NSString * password;
@property (nonatomic, retain) NSString * username;
@property (nonatomic, retain) NSNumber * id;
@property (nonatomic, retain) ApiKey *apiKeyRelationship;
@property (nonatomic, retain) NSSet *positionRelationship;
@property (nonatomic, retain) SecretApiKey *secretApiKeyRelationship;
@end
@interface UserData (CoreDataGeneratedAccessors)
- (void)addPositionRelationshipObject:(Positions *)value;
- (void)removePositionRelationshipObject:(Positions *)value;
- (void)addPositionRelationship:(NSSet *)values;
- (void)removePositionRelationship:(NSSet *)values;
這是位置enitiy:
@class UserData;
@interface Positions : NSManagedObject
@property (nonatomic, retain) NSString * amount;
@property (nonatomic, retain) NSString * base;
@property (nonatomic, retain) NSNumber * id;
@property (nonatomic, retain) NSString * pl;
@property (nonatomic, retain) NSString * status;
@property (nonatomic, retain) NSString * swap;
@property (nonatomic, retain) NSString * symbol;
@property (nonatomic, retain) NSString * timestamp;
@property (nonatomic, retain) UserData *positionRelationship;
@end
可能有人向我解釋如何爲現有用戶保存新職位?
得到這個:CoreData:錯誤:無法致電該行NSManagedObject類「的UserData」指定初始化'的NSMutableSet * USERSET = [用戶mutableSetValueForKey:@「positionRelationship」];' –
我已經想通了如何與答案做到這一點由@quellish給出。謝謝你的幫助。 –