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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:00:09+00:00 2026-05-13T19:00:09+00:00

I have a data model with three entities (Purchase, Items, Image) the purchase is

  • 0

I have a data model with three entities (Purchase, Items, Image) the purchase is the main with the other two as related attributes.

I need to be able to send the data to a web server, and I must encode in base64, I have a couple of classes that take care of the encoding and decoding that i downloaded from the net, they are categories for the NSData class, but when i use them i receive back a null string.

     // For Error Information
 NSError *error;

 // Create a File Manager
 NSFileManager *fileManager = [NSFileManager defaultManager];

 // Point to the Documents Directory
 NSString *documentsDirectory = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];

 // File we want to create in the Documents Directory
 NSString *filePath = [documentsDirectory stringByAppendingPathComponent:@"dataArray.txt"];

 NSString *joined = [self.dataList componentsJoinedByString:@","];

 NSData *myData = [NSData dataWithBase64EncodedString:joined];
 NSLog(@"%@", myData); // THIS IS NULL
 [myData writeToFile:filePath atomically:YES];

SO the array spits out this…

   <Purchase: 0x502b7a0> (entity: Purchase; id: 0x502a620 <x-coredata://92618241-3890-45FD-B1D7-7F17D52CAF38/Purchase/p22> ; data: {
    amount = 123.56;
    image = 0x502c7b0 <x-coredata://92618241-3890-45FD-B1D7-7F17D52CAF38/Image/p11>;
    items = "<relationship fault: 0x5024900 'items'>";
    latitude = 37.331689;
    longitude = -122.030731;
    name = "Macy's";
    thumbnailImage = "(...not nil..)";
    timestamp = 2010-02-18 18:03:03 -0500;
    type = nil;
}),<Purchase: 0x502bdf0> (entity: Purchase; id: 0x502a630 <x-coredata://92618241-3890-45FD-B1D7-7F17D52CAF38/Purchase/p20> ; data: {
    amount = 12.34;
    image = 0x502c8e0 <x-coredata://92618241-3890-45FD-B1D7-7F17D52CAF38/Image/p9>;
    items = "<relationship fault: 0x502ef40 'items'>";
    latitude = 37.331689;
    longitude = -122.030731;
    name = Rippers;
    thumbnailImage = "(...not nil..)";
    timestamp = 2010-02-18 12:18:34 -0500;
    type = Travel;
}),<Purchase: 0x502c0e0> (entity: Purchase; id: 0x502a640 <x-coredata://92618241-3890-45FD-B1D7-7F17D52CAF38/Purchase/p21> ; data: {
    amount = 5.56;
    image = 0x502ca40 <x-coredata://92618241-3890-45FD-B1D7-7F17D52CAF38/Image/p10>;
    items = "<relationship fault: 0x502f6a0 'items'>";
    latitude = 37.331689;
    longitude = -122.030731;
    name = "Roy Rogers";
    thumbnailImage = "(...not nil..)";
    timestamp = 2010-02-18 17:45:03 -0500;
    type = Clothing;
}),<Purchase: 0x502c320> (entity: Purchase; id: 0x502a650 <x-coredata://92618241-3890-45FD-B1D7-7F17D52CAF38/Purchase/p16> ; data: {
    amount = 5.52;
    image = nil;
    items = "<relationship fault: 0x502f9e0 'items'>";
    latitude = 37.331689;
    longitude = -122.030731;
    name = heariam;
    thumbnailImage = nil;
    timestamp = 2010-02-18 09:41:35 -0500;
    type = nil;
})

How do i encode this to a base64 string so i can email it to the webserver

any help is greatly appreciated, or even a point in the right direction, I am still very new to programming.

  • 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-13T19:00:09+00:00Added an answer on May 13, 2026 at 7:00 pm

    Is the linker giving your a warning that, “NSData may not respond to dataWithBase64EncodedString”?

    If so, the problem is that your categories are not properly imported and the method does not exist as far as this code segment is concerned. Make sure you import the categories into the header or the implementation for whatever class the code above belongs to.

    Edit01

    I just noticed that your loading an array of NSManagedObjects. I don’t think NSData can convert unfaulted managed objects. You have to fire the fault on all the properties including relationships.

    Try setting the fetch you use to get the objects to return return the objects faulted.

    [dataListFetch setReturnsObjectsAsFaults:NO]; // or yes, I always get the two reversed.
    

    When you print out a faulted NSManagedObject a relationship doesn’t look like:

    items = "<relationship fault: 0x5024900 'items'>";
    

    Instead it dumps the object/s at other end of the relationship. If your graph is very complex, you can get a very extensive dump.

    Core Data graphs can be very complex and difficult to serialize/archive. Indeed, Core Data exist to handle graphs that cannot be easily represented by arrays and dictionaries.

    To make the graph simple enough to upload, you might have to create array or dictionary objects and populate them with the values of the managed objects. Then convert that to data.

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

Sidebar

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.