0
我想要一個可變的NSSet照片,並將照片隨機存儲在我的Xcode xcdatamodel中。我知道NSSet用於存儲隨機對象,但有沒有辦法將NSSet更改爲NSArray或跟蹤NSSet變量中的序列插入?iOS:跟蹤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索引仍在改變。
之間來回變換的0指數仍然改變我每次刷新的時間。 –
即使使用NSOrderedSet? – michaels
謝謝!發現我需要將關係的屬性從NSSet更改爲NSOrderedSet。 –