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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T14:12:31+00:00 2026-05-20T14:12:31+00:00

I think this is pretty simple but i’m new to Objective-C, IOS and Core

  • 0

I think this is pretty simple but i’m new to Objective-C, IOS and Core Data.

I have a Core Data entity called EnquiryStore, which contains various attributes “name”, “address”, “enquiry” etc..

I can fetch the results fine but I struggling to understand how the results are stored! Which is making it hard for me to do the next part of my program which is to export the data to CSV using Dave DeLong’s CHCSVWriter. I understand that to use

[array writeToCSVFile:outputCSVFile atomically: NO];

It will accept an Array of Arrays, is this what Core Data gives me? Because i can’t get it to work with that method.

I could use

[myCSVWriter writeField: ...];
[myCSVWriter writeLine];

but this seems long winded as I will have to build the string from each attribute from Core Data.

  • 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-20T14:12:31+00:00Added an answer on May 20, 2026 at 2:12 pm

    You are the only person that knows how your NSManagedObject looks like, it could have relationships which would be impossible to put in a csv file. It could have binary data which would not be very useful in a csv file. Or it just could have attributes that you don’t want to export. And you have to decide in which order you want your csv exported too.

    It’s easy to create a NSArray (ie the list of NSManagedObjects you want to export) of NSArray (ie the list of exported attributes for that object). Just enumerate through all your NSManagedObject and fill an array with the values you want to export.

    You could use something like this:

    NSArray *objectsForExport = ... /* get it through a fetch request... helper function... whatever */
    NSArray *exportKeys = [NSArray arrayWithObjects:@"foo", @"bar", @"name", @"city", @"address", nil];
    
    NSMutableArray *csvObjects = [NSMutableArray arrayWithCapacity:[objectsForExport count]];
    for (NSManagedObject *object in objectsForExport) {
        NSMutableArray *anObjectArray = [NSMutableArray arrayWithCapacity:[exportKeys count]];
        for (NSString *key in exportKeys) {
            id value = [object valueForKey:key];
            if (!value) {
                value = @"";
            }
            [anObjectArray addObject:[value description]];
        }
        [csvObjects addObject:anObjectArray];
    }
    

    and there you have your array of arrays.

    I believe there was a method that returned an NSArray of values if you pass it a NSArray of keys, but I can not find it, and I can’t remember its name or even to which class it belonged.

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

Sidebar

Related Questions

I think this should be pretty simple, but I'm a SQL newb. I have
I think this is a pretty simple question but I'm having trouble finding the
I think this might be a pretty simple question, but I haven't been able
I have a simple winphone7 application, but I think this would apply to any
This ought to be pretty simple, maybe use a regex but I would think
I think this may sound pretty simple, but still I can not get it
I have this pretty simple application, it uses a webService to transfer data to
So this should be pretty simple, but it isn't working. I have the following
I think this may be a pretty simple ActiveRecord problem to solve but if
I think this is a pretty simple thing to do, but I don't know

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.