I have a NSMutableOrderedSet property named currentSongsList on a NSObject subclass. I have a NSData property named currentSongsList on a NSManagedObject subclass.
I want to archive the NSMutableOrderedSet property into the database, so that it can be retrieved after my app is terminated and restarted.
In CurrentSongsInfo.h -
@interface CurrentSongsInfo : NSObject
@property (nonatomic, strong) NSMutableOrderedSet *currentSongsList;
In CurrentSongsInfoArchive.h -
@interface CurrentSongsInfoArchive : NSManagedObject
@property (nonatomic, retain) NSData * currentSongsList;
In CurrentSongsInfoArchive.m -
DatabaseInterface *databaseInterfacePtr = [[DatabaseInterface alloc] init];
// Not showing code for databaseInterfacePtr:newManagedObjectOfType, but it has been working for over a year for many entity types
CurrentSongsInfoArchive *currentSongsInfoArchive = (CurrentSongsInfoArchive *)[databaseInterfacePtr newManagedObjectOfType:@"CurrentSongsInfoArchive"];
NSData *currentSongsList = [NSKeyedArchiver archivedDataWithRootObject:currentSongsInfoArchive.currentSongsList];
currentSongsInfoArchive.currentSongsList = currentSongsList;
When the above code from CurrentSongsInfoArchive.m runs, I see the following output:
currentSongsList.count = 540
2014-09-19 04:30:57.219 MusicByCarlCoreData[2863:1091413] currentSongsInfoArchive.currentSongsList.length = 135
I have four other NSMutableOrderedSet properties, whose count values are all different. But when they are archived into the CurrentSongsInfoArchive object, their length is always 135.
NSMutableOrderedSet conforms to NSSecureCoding, but is it even possible to save a NSMutableOrderedSet to an attribute in a NSManagedObject subclass?