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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:27:02+00:00 2026-06-07T23:27:02+00:00

I’m having a problem with Core Data. I have two Entities (Article and Manufacturer)

  • 0

I’m having a problem with Core Data. I have two Entities (Article and Manufacturer) (one containing a transformable attribute which is an array of the other entity). Everything’s working fine till I try to add the array to the NSManagedObject. Here’s some code:

@implementation HASArticleInitializer

- (void)initialize:(NSArray *)initArray {
    //Alloc and init some local variables
    NSMutableArray *articleEntitiesArray = [NSMutableArray alloc] init];
    for (NSInteger pageIndex = 1; pageIndex <= pageCount; pageIndex++) {

        //Parsing the website

        //For-loop for every object on every page
        for (NSInteger object = 0; object < [articleNumbersOnOnePageArray count]; object++) {
            //Doing other string manipulation and parsing stuff


            NSManagedObject *newArticleEntry = [NSEntityDescription insertNewObjectForEntityForName:@"Article"inManagedObjectContext:context];

            [newArticleEntry setValue:[NSString stringWithFormat:@"%@_%@", manufacturerNumber, articleNumber] forKey:@"number"];
            [newArticleEntry setValue:articleTextComplete forKey:@"text"];
            [newArticleEntry setValue:articleStatus forKey:@"status"];
            [newArticleEntry setValue:manufacturerName forKey:@"manufacturerName"];
            [newArticleEntry setValue:manufacturerNumber forKey:@"manufacturerID"];

            [articleEntitiesArray addObject:newArticleEntry];
        }
    }

    NSManagedObject *newManufacturerEntry = [NSEntityDescription insertNewObjectForEntityForName:@"Manufacturer" inManagedObjectContext:context];

    //Encoding the NSArray and setting the entity attribute to Binary Data doesn't work neither
    //NSData *arrayData = [NSKeyedArchiver archivedDataWithRootObject:articleEntitiesArray];

    [newManufacturerEntry setValue:manufacturerName forKey:@"name"];
    [newManufacturerEntry setValue:manufacturerNumber forKey:@"manufacturerID"];
    [newManufacturerEntry setValue:manufacturerCount forKey:@"count"];
    [newManufacturerEntry setValue:articleEntitiesArray forKey:@"articles"];
    NSLog(@"%@", articleEntitiesArray);
}


@end

I tried everything I thought it could or couldn’t help, I’ve really spend days on this, but I always get the following error when the AppDelegate’s - (IBAction)saveAction:(id)sender method is called:

[15836:a057] -[NSManagedObject encodeWithCoder:]: unrecognized selector sent to instance 0x1001896e0
[15836:a057] An uncaught exception was raised
[15836:a057] -[NSManagedObject encodeWithCoder:]: unrecognized selector sent to instance 0x1001896e0
[15836:a057] (
0   CoreFoundation                      0x00007fff8dc94716 __exceptionPreprocess + 198
1   libobjc.A.dylib                     0x00007fff8bfe6470 objc_exception_throw + 43
2   CoreFoundation                      0x00007fff8dd2ad5a -[NSObject(NSObject) doesNotRecognizeSelector:] + 186
3   CoreFoundation                      0x00007fff8dc82c3e ___forwarding___ + 414
4   CoreFoundation                      0x00007fff8dc82a28 _CF_forwarding_prep_0 + 232
5   Foundation                          0x00007fff86931401 _encodeObject + 1163
6   Foundation                          0x00007fff869323cc -[NSKeyedArchiver _encodeArrayOfObjects:forKey:] + 410
7   Foundation                          0x00007fff869320c9 -[NSArray(NSArray) encodeWithCoder:] + 473
8   Foundation                          0x00007fff86931401 _encodeObject + 1163
9   Foundation                          0x00007fff869358f9 +[NSKeyedArchiver archivedDataWithRootObject:] + 182
10  iLoadPix                            0x0000000100003c21 -[HASArticleInitializer initialize:] + 3793
11  Foundation                          0x00007fff86926842 __NSThread__main__ + 1345
12  libsystem_c.dylib                   0x00007fff88553782 _pthread_start + 327
13  libsystem_c.dylib                   0x00007fff885401c1 thread_start + 13

Core Data Model:
Entity 1
Entity 2

As I said, everything works fine if I don’t save the array, the NSLog is correct, too. If it matters I use NSThreads (but I don’t think so because everything else works just fine) 🙁

Please help me! Thanks so much in advance! 🙁

  • 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-07T23:27:04+00:00Added an answer on June 7, 2026 at 11:27 pm

    Transformable properties are archived via keyed archiving/unarchiving… however NSManagedObject isn’t designed to be archived this way. (It doesn’t implement the NSCoding protocol.)

    To get around this you could turn your managed objects into dictionary representations, but the most natural thing seems to be to use a core data relationship between the 2 entities. Is there a reason you didn’t model a relationship here?

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a text area in my form which accepts all possible characters from
I have two tables with like below codes: Table: Accounts id | username |
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't

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.