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 8544033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:27:18+00:00 2026-06-11T12:27:18+00:00

I am creating an iPad App that displays data I got from an API

  • 0

I am creating an iPad App that displays data I got from an API in JSON format. My Core Data model has several entities(Countries, Events, Talks, …). For each entity I have one .json file that contains all instances of the entity and its attributes as well as its relationships.

I would like to populate my Core Data data model with these entities before the start of the App (otherwise it takes about 15 minutes for the iPad to create all the instances of the entities from the several JSON files using factory methods).

I am currently importing the data into CoreData like this:

-(void)fetchDataIntoDocument:(UIManagedDocument *)document
{
dispatch_queue_t dataQ = dispatch_queue_create("Data import", NULL);
dispatch_async(dataQ, ^{
        //Fetching data from application bundle
    NSURL *countriesurl = [[NSBundle mainBundle] URLForResource:@"contries" withExtension:@"json"];
    NSURL *eventsurl = [[NSBundle mainBundle] URLForResource:@"events" withExtension:@"json"];

        //converting the JSON files to NSDictionaries
    NSError *error = nil;
    NSDictionary *countries = [NSJSONSerialization JSONObjectWithData:[NSData dataWithContentsOfURL:countriesurl] options:kNilOptions error:&error];
    countries = [countries objectForKey:@"countries"];
    NSDictionary *events = [NSJSONSerialization JSONObjectWithData:[NSData dataWithContentsOfURL:eventsurl] options:kNilOptions error:&error];
    events = [events objectForKey:@"events"];

        //creating entities using factory methods in NSManagedObject Subclasses (Country / Event)
    [document.managedObjectContext performBlock:^{
        NSLog(@"creating countries");
        for (NSDictionary *country in countries) {
            [Country countryWithCountryInfo:country inManagedObjectContext:document.managedObjectContext]; //creating Country entities
        }
        NSLog(@"creating events");
        for (NSDictionary *event in events) {
            [Event eventWithEventInfo:event inManagedObjectContext:document.managedObjectContext]; // creating Event entities
        }
        NSLog(@"done creating, saving document");
        [document saveToURL:document.fileURL forSaveOperation:UIDocumentSaveForOverwriting completionHandler:NULL];
    }];
});
dispatch_release(dataQ);
}

This combines the different JSON files into one UIManagedDocument which i can then perform fetchRequests on to populate tableViews, mapView, etc.

I’m looking for a way to create this document outside my application & add it to the mainBundle. Then I could copy it once to the apps DocumentsDirectory and be able I use it (instead of creating the Document within the app from the original JSON files). Any help is appreciated!

  • 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-06-11T12:27:19+00:00Added an answer on June 11, 2026 at 12:27 pm

    It looks like your initial data is static anyway. Why not just run this code, and create a copy of the database in the simulator, then just include that database in the resource bundle.

    You can copy that database into a production database, or you can use a second PSC and even mark your provided database as readonly. Apple frowns on stuff in Documents that the user does not create, so this has additional benefits.

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

Sidebar

Related Questions

I am creating an iPad app that has several pictures ( UIImageViews ) in
How would one go about creating an ipad app that has a similar view
I'm creating an iphone/ipad app that basically reads XML documents and creates tableviews from
I'm creating a layout for an iPad app that will consist of xx number
In the iPad app that I'm creating, I'm trying to handle the uncaught Exceptions
I am trying to develop a splitView based iPad app, that displays the split
I'm creating an iPad app for 3.2 and later. My app has an overlay
I am creating an Universal app that has a scroll view. The app runs
I am creating an iPad app which is a form with mostly text boxes.
I am creating an iPad app using XCode 4 and Storyboards. I have a

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.