Variations of this question have been asked here and here, but it appears that the question hasn’t received a clear answer.
The problem that I face is that the MPMediaLibrary framework keeps a reference to each MPMediaItem (music, video, podcast, …) as an usigned long long (uint64_t), but I can’t seem to find a way to store this value using Core Data. Using Integer 64 as the data type doesn’t seem to do the trick and I don’t see an alternative.
Since there’s no support for
unsigned long longin Core Data you might need to literally “do the trick” yourself.One of the ideas is to store the value as …binary data, and define custom accessors that return the data as
uint64_t:It seems to do the job. The code below:
Outputs:
A hack like this of course adds a level of indirection, and it may affect performance when
timestampis heavily used.