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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:05:36+00:00 2026-05-22T03:05:36+00:00

I’m creating a simple iOS application consisting of a few UITableViewControllers. The information displayed

  • 0

I’m creating a simple iOS application consisting of a few UITableViewControllers. The information displayed in the view controllers will come from a text file (that I’ll include in the project’s Resources). The text file’s contents will come from a spreadsheet.

Since this is my first time working with Core Data I have a few questions:

  • What format is most common for the text file? CSV, XML or something else?
  • What’s the easiest way to import the data?

A few notes:

  • The data is static. Ideally the app will load the data into “Core Data” just once (1st time the app is run).
  • Each additional run of the app will just pull data from some Core Data source (that I’m not completely familiar w/ yet) instead of re-loading it from the textfile.
  • 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-22T03:05:37+00:00Added an answer on May 22, 2026 at 3:05 am

    If the data is structured in a relational way then XML or JSON allows that structure to be easily preserved and then easily parsed and saved in your Core Data store. You’ll need to use an XML or JSON parser, which will turn your data into an array of dictionaries (or multiple levels thereof if your data structure requires it). You’ll simply iterate through the array and dig into the dictionaries (and sub-arrays and sub-dictionaries, if appropriate) and add objects to your store as you go.

    If it’s flat data, a simple single table that will become a single entity in Core Data, then tab-delimited or CSV text files are fine (and tab-delimited is even easier to parse if there wouldn’t be any tabs within the data itself). You can then grab individual rows, break the rows down into an array of data bits (this is where tab delimiting makes is super-simple), create a new object for each row, set its properties to the array elements, and save the context.

    The XML/JSON version is more complex than is worth writing out here — search SO and you’ll find lots of examples — but here’s the tab-delimited version (this assumes you don’t have a gigantic ball of data that can’t reasonably be held in memory):

    // Standard Core Data setup here, grabbing the managedObjectContext, 
    //     which is what I'll call it
    // Then parse your text
    NSString *path = [[NSBundle mainBundle] pathForResource:@"YourTextFileName" ofType:@"txt"];
    NSString *content = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:NULL];
    NSArray *rows = [content componentsSeparatedByString:@"\n"];
    // Now that we have rows we can start creating objects
    YourManagedObject *yourManagedObject = nil;
    for (NSString *row in rows) {
      NSArray *elements = [row componentsSeparatedByString:@"\t"];
      YourManagedObject *yourManagedObject = (YourManagedObject *)[NSEntityDescription insertNewObjectForEntityForName:@"YourManagedObject" inManagedObjectContext:managedObjectContext;
      [YourManagedObject setName:[elements objectAtIndex:0]];
      [YourManagedObject setCountry:[elements objectAtIndex:1]];
      // Etc. You may need an NSNumberFormatter and/or an NSDateFormatter to turn
      //   your strings into dates and numbers, depending on your data types
      [managedObjectContext save];
    }
    

    Poof, all done.

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

Sidebar

Related Questions

No related questions found

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.