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

In an application we are developing, I have access to a database table which
I'm developing a master-slave command model by which some application Master sends commands to
I've been evaluating technology stack for developing a social network based application. Below are
I am developing an application that manages a photo contest. In that application, I
I am working for a developing firm and am doing a major redesign on
In a concept proof I'm developing, I've built the folowing scheme: _ A _
A year ago I was a big fan of .NET. I was developing custom
I am a student and in last semester i develop asp.net application - Payment
My team is in the process of developing a system where we're using Unity
Possible Duplicate: What is so bad about Singletons? It's understandable that many design patterns

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.