Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7583535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:42:08+00:00 2026-05-30T18:42:08+00:00

Variations of this question have been asked here and here , but it appears

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T18:42:09+00:00Added an answer on May 30, 2026 at 6:42 pm

    Since there’s no support for unsigned long long in 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:

    // header
    @interface Event : NSManagedObject
    
    @property (nonatomic, retain) NSData * timestamp;
    
    - (void)setTimestampWithUInt64:(uint64_t)timestamp;
    - (uint64_t)timestampUInt64;
    
    @end
    
    
    // implementation
    @implementation Event
    
    @dynamic timestamp;
    
    - (void)setTimestampWithUInt64:(uint64_t)timestamp
    {
        self.timestamp = [NSData dataWithBytes:&timestamp length:sizeof(timestamp)];
    }
    
    - (uint64_t)timestampUInt64
    {
        uint64_t timestamp;
        [self.timestamp getBytes:&timestamp length:sizeof(timestamp)];
        return timestamp;
    }
    
    @end
    

    It seems to do the job. The code below:

    Event *event = [NSEntityDescription insertNewObjectForEntityForName:@"Event"
                    inManagedObjectContext:self.managedObjectContext];
    
    uint64_t timestamp = 119143881477165;
    NSLog(@"timestamp: %llu", timestamp);
    
    [event setTimestampWithUInt64:timestamp];
    [self.managedObjectContext save:nil];
    
    NSFetchRequest *request = [NSFetchRequest fetchRequestWithEntityName:@"Event"];
    Event *retrievedEvent = [[self.managedObjectContext executeFetchRequest:request
                               error:nil] lastObject];
    NSLog(@"timestamp: %llu", [retrievedEvent timestampUInt64]);
    

    Outputs:

    2012-03-03 15:49:13.792 ulonglong[9672:207] timestamp: 119143881477165
    2012-03-03 15:49:13.806 ulonglong[9672:207] timestamp: 119143881477165
    

    A hack like this of course adds a level of indirection, and it may affect performance when timestamp is heavily used.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that variations on this question have been asked, but I've tried all
Variations of this question have been asked, but not specific to GNU/Linux and C.
I see variations of this question have been asked a couple of times, but
Variations of this question have been asked before, but it seems like the issue
Variations on this question have been asked, but not this specifically. I have a
It seems that others have had variations on this question, but from what I
This is a variation on a question that has been asked here several times.
I know this question has been asked in several variations before, but my question
I know there have been plenty of variations on this question before, but none
Variations on this question have been asked many times. Vertical centering with CSS is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.