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

  • SEARCH
  • Home
  • 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 3219300
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:37:46+00:00 2026-05-17T15:37:46+00:00

I am developing an application which demands around 100 images or maybe more to

  • 0

I am developing an application which demands around 100 images or maybe more to be pre-inserted into the Core Data database along with other related information.

Now I can easily add other data by just writing a few lines of code but for UIImages I am unsure how to do it without writing a lot of code. I was wondering: is there anyway to do this easily, or if there isn’t what’s the best way to achieve this with the least amount of effort.

Also, is it okay to store images in a Core Data database or should we only only save the addresses of images on the local file system?

  • 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-17T15:37:47+00:00Added an answer on May 17, 2026 at 3:37 pm

    Storing images within a Core Data database is pretty easy to do. You just need to mark your image attribute as a transformable one and create a subclass of NSValueTransformer. Within that subclass, add code like the following:

    + (Class)transformedValueClass 
    {
        return [NSData class]; 
    }
    
    + (BOOL)allowsReverseTransformation 
    {
        return YES; 
    }
    
    - (id)transformedValue:(id)value 
    {
        if (value == nil)
            return nil;
    
        // I pass in raw data when generating the image, save that directly to the database
        if ([value isKindOfClass:[NSData class]])
            return value;
    
        return UIImagePNGRepresentation((UIImage *)value);
    }
    
    - (id)reverseTransformedValue:(id)value
    {
        return [UIImage imageWithData:(NSData *)value];
    }
    

    For your transformable attribute, specify this subclass’s name as the Value Transformer Name.

    You can then create an NSManagedObject subclass for the entity hosting this image attribute and declare a property for this image attribute:

    @property(nonatomic, retain) UIImage *thumbnailImage;
    

    You can read UIImages from and write UIImages to this property and they will be transparently changed to and from NSData to be stored in the database.

    Whether or not to do this depends on your particular case. Larger images probably should not be stored in this manner, or at the least should be in their own entity so that they are not fetched into memory until a relationship to them is followed. Small thumbnail images are probably fine to put in your database this way.

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

Sidebar

Related Questions

When developing an application which mostly interacts with a database, what is a good
I`m developing an application which receives data from my GPS device like coordinates, speed
I'm developing an application which needs to store large amounts of data. I cannot
i am developing application which send and receive data between two computers but there
I am developing an application which at the moment queries a (rather large) database
I am developing an application which communicates with an SQL Server 2005 database to
I am developing an application which will be connected to Access database at the
Im developing an application which having Images as a Index on selection of particular
I am developing an application which has around 8 Activities, and a class which
I have heard that when developing application which uses a database you should do

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.