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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:26:37+00:00 2026-06-16T00:26:37+00:00

I need to save array in core data, so i read that I can

  • 0

I need to save array in core data, so i read that I can use NSData for it. So I think that I have problem with archiving.

NSMutableArray *newArray = [[NSMutableArray alloc]init];
NSData *newData = [NSKeyedArchiver archivedDataWithRootObject:newArray];
[myEntity setValue:newData forKey:@"nameOfMyData"];

And then I try to pick my array in another VIewController for filling

NSData *newdata = [NSData dataWithData:self.myEntity.nameOfMyData];
NSMutableArray *photoArray = [[NSMutableArray alloc]init];
photoArray = [NSKeyedUnarchiver unarchiveObjectWithData:newdata];

I have no crash, but in command line appear next:

[NSKeyedUnarchiver initForReadingWithData:]: data is empty; 
did you forget to send -  finishEncoding to the NSKeyedArchiver?

And when i try to add object to my array, it does not add

[photoArray addObject:myImage];

So myImage is creating and with it I have no trouble, but in debugger always write for photoArray:

photoArray = (NSMutableArray*) 0x00000000 0 objects
  • 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-16T00:26:38+00:00Added an answer on June 16, 2026 at 12:26 am

    It should work. But when unarchiving the array rather use:

    NSData *newdata = [NSData dataWithData:self.myEntity.nameOfMyData];
    NSMutableArray *photoArray = [NSMutableArray arrayWithArray: [NSKeyedUnarchiver unarchiveObjectWithData:newdata]];
    

    You either have objects in your array that dont conform to NSCoding protocol or you do not save your core data context (or saving is unsuccessful).

    After archiving with

    NSData *newData = [NSKeyedArchiver archivedDataWithRootObject:newArray];
    

    what do you see when you check newData for nil? I suppose it is nil.

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

Sidebar

Related Questions

I have an array of ushort pixel data that I need to save as
I have an NSMutableArray with 24 strings. I need to save this data if
I need to save data array to CSV file. The problem is the following:
I need to save on shared preferences some array of Strings and after that
I am doing tests in Core Data and have an array with approx. 230
I'm doing this project that I need to save a full character array into
I have a big problem, I need to save an AJAXed ordered list as
I need to save data (assoc array with 6 values) to database table. What
Good day. I have an NSMutableArray that contains references to objects. I need to
I need to save to an isolated storage the total time that the user

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.