Frage

I want have a variable NSSet photos and it stores the photos randomly in my Xcode xcdatamodel. I know NSSet is use to store random object but is there a way to either change the NSSet to NSArray or keep track of the sequence insert in the NSSet variable?

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]];

[Updated]:

I realise even if I used

[_model.photos allObjects] objectAtIndex:0]

The 0 index still changing every time I refresh.

War es hilfreich?

Lösung

NSOrderedSet maintains the order.

You can also use setWithArray: and allObjects to transform back and forth between NSSet and NSArray

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top