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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:24:19+00:00 2026-05-31T15:24:19+00:00

In my application i have an custom NSObject, which contains 2 mutable Arrays. I

  • 0

In my application i have an custom NSObject, which contains 2 mutable Arrays.
I need to save this custom NSOBject into a core data entity, but i have no real idea how i can accomplish that…

After some searching, i found out, that the best way would be to convert the nsobject to nsdata and save it in an transformable field of the entity… but i m not sure how to do that.
can someone help me?

heres to code for my custom object:

MeasureData.h

@interface MeasureData : NSObject{
}

@property (nonatomic, strong) NSMutableArray *questionsData;
@property (nonatomic, strong) NSMutableArray *answersData;

- (id) init;

@end

MeasureData.m

#import "MeasureData.h"

@implementation MeasureData

@synthesize questionsData;
@synthesize answersData;

#pragma mark -
#pragma mark int

- (id)init
{
self = [super init];

// Initalize questions array (width data from plist)
questionsData = self.makeQuestionsArray;
// NSLog(@"loaded questions array: %@",questionsData); // debug


// Initalize answers array
answersData = self.makeAnswersArray;
// NSLog(@"loaded answers array: %@",answersData); // debug


return self;
}

-(NSMutableArray *)makeQuestionsArray
{
// Initalize questions array (width data from plist)
NSString *path = [[NSBundle mainBundle] pathForResource:
                  @"questions.list" ofType:@"plist"];
NSMutableArray *questions = [NSMutableArray arrayWithContentsOfFile:path];


/*
 [questionsData insertObject:(NSString *)string atIndex:0];
 */

return questions;
}

-(NSMutableArray *)makeAnswersArray
{
// Initalize answers array
NSMutableArray *answers = [NSMutableArray arrayWithCapacity:0];

return answers;
}

-(id)initWithCoder:(NSCoder *)decoder {
if ((self=[super init])) {
    questionsData = [decoder decodeObjectForKey:@"questionsData"];
    answersData = [decoder decodeObjectForKey:@"answersData"];
}
return self;
}

-(void)encodeWithCoder:(NSCoder *)encoder {
[encoder encodeObject:questionsData forKey:@"questionsData"];
[encoder encodeObject:questionsData forKey:@"questionsData"];
}

@end

According to the first comment, i implemented the encoder/coder functions for my custom class. And tried to archive and encode it (i m new to ios, so it could be completly wrong) – but it dont work… can someone tell me whats wrong?

heres the encoding (which dont work XD):

NSMutableData *dataToSave = (NSMutableData *)self.measureData;
NSKeyedArchiver *archiverForData = [[NSKeyedArchiver alloc] initForWritingWithMutableData:dataToSave];

[archiverForData encodeObject:dataToSave forKey:@"dataToSave"];
[archiverForData finishEncoding];
//

//theMeasure is the CoreData Entity
theMeasure.result = dataToSave;
  • 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-31T15:24:20+00:00Added an answer on May 31, 2026 at 3:24 pm

    In outline:

    • create a NSMutableData
    • create a NSKeyedArchiver with initForWritingWithMutableData over your data
    • serialize your arrays / objects / whatever you need (that implements NSCoding) with encode… methods of NSCoder
    • create a managed object with a BLOB (binary data) type field
    • write your encoded data from the mutable data to this field of the managed object.

    In my answer to this question you can find some useful links: NSCoding VS Core data

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

Sidebar

Related Questions

I'm looking into some XSS prevention in my Java application. I currently have custom
I have a custom built application framework written in PHP which I have been
I have an application in which I have an XML based application. This is
In my application I have a custom dialog which display some unwanted margin at
I have an application where I have one custom view which is derived from
I have an application where I need to have a custom setting page. In
In my Delphi application I have a custom Yes, No, Cancel dialogue, which will
I have custom view in my application which can be scrolled by the user.
I have an application which has a tabcontrol that contains two tabpages. I have
In my application I have a custom model binder that I set to the

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.