我想要一个可变的NSSet照片,并将照片随机存储在我的Xcode xcdatamodel中。我知道NSSet用于存储随机对象,但有没有办法将NSSet更改为NSArray或跟踪NSSet变量中的序列插入?
Article.h
@property (nonatomic, retain) NSSet *photos;
Article.m
RKManagedObjectMapping *_mapping = (RKManagedObjectMapping*)[RKManagedObjectMapping generatedManagedObjectMappingFromClass:[self class] keyUnderscored:NO excludesProperties:[NSArray arrayWithObjects:@"attachments", @"videos", @"photos", nil]];
[_mapping mapKeyPath:@"photos.photo" toRelationship:@"photos" withMapping:(RKManagedObjectMapping*)[BTAttachment rkObjectMapping]];
[_mapping mapKeyPath:@"attachments.attachment" toRelationship:@"attachments" withMapping:(RKManagedObjectMapping*)[BTAttachment rkObjectMapping]];
[更新] :
我意识到即使我用过
[_model.photos allObjects] objectAtIndex:0]
每次刷新时0索引仍在变化。