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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T17:09:47+00:00 2026-06-03T17:09:47+00:00

I would like to know if it’s possible to init a subclass of NSManagedObject

  • 0

I would like to know if it’s possible to init a subclass of NSManagedObject ?
I have a class “Actualite” which is a subclass of NSManagedObject and when I want to initialize this class, I get this error :
“CoreData: error: Failed to call designated initializer on NSManagedObject class Actualite”, and the app crashes after this message “-[Actualite setTitre:]: unrecognized selector sent to instance 0x8433be0”

Here is my code :

-(void) recupererActualites {
listeNouvellesActualites = [[NSMutableArray alloc] init];

// Convert the supplied URL string into a usable URL object
NSURL *url = [NSURL URLWithString:FACE06_RSS];

// Create a new rssParser object based on the TouchXML "CXMLDocument" class, this is the
// object that actually grabs and processes the RSS data
CXMLDocument *rssParser = [[CXMLDocument alloc] initWithContentsOfURL:url encoding:NSUTF8StringEncoding options:0 error:nil];

// Create a new Array object to be used with the looping of the results from the rssParser
NSArray *resultNodes = NULL;

// Set the resultNodes Array to contain an object for every instance of an  node in our RSS feed
resultNodes = [rssParser nodesForXPath:@"//item" error:nil];

NSMutableArray* tmp = [[NSMutableArray alloc] init];
for (CXMLElement* resultElement in resultNodes) {
    // Create a temporary MutableDictionary to store the items fields in, which will eventually end up in blogEntries
    NSMutableDictionary *blogItem = [[NSMutableDictionary alloc] init];
    NSMutableArray* categories = [[NSMutableArray alloc] init];

    // Create a counter variable as type "int"
    int counter;

    // Loop through the children of the current  node
    for(counter = 0; counter < [resultElement childCount]; counter++) {
        // Add each field to the blogItem Dictionary with the node name as key and node value as the value
        if([[[resultElement childAtIndex:counter] name] isEqual:@"category"])
            [categories addObject:[[resultElement childAtIndex:counter] stringValue]];
        else {
            if ([[resultElement childAtIndex:counter] stringValue] != nil)
                [blogItem setObject:[[resultElement childAtIndex:counter] stringValue] forKey:[[resultElement childAtIndex:counter] name]];
            else
                [blogItem setObject:@"" forKey:[[resultElement childAtIndex:counter] name]];
        }
    }

    Actualite* actu = [[Actualite alloc] init];
    [blogItem setObject:categories forKey:@"categories"];
    [actu initWithDictionnary:blogItem];
    [tmp addObject:actu];
    //[actu release];

    [categories release];
    [blogItem release];
}
listeNouvellesActualites = tmp;

[rssParser release];
resultNodes = nil;

// Stockage des actualités en local
[self stockerActualites];
}

And the initWithDictionary method set all the attributes of the Actualite class.

I also tried

Actualite* actu = [[Actualite alloc] initWithEntity:[NSEntityDescription entityForName:@"Actualite" inManagedObjectContext:managedObjectContext] insertIntoManagedObjectContext:managedObjectContext]; 

and

Actualite* actu = (Actualite*)[NSEntityDescription entityForName:@"Actualite" inManagedObjectContext:managedObjectContext]; 

instead of

Actualite* actu = [[Actualite alloc] init]; 

The errors disappear but the app stops at this point. I don’t know what can I do…

Is someone already had this problem ?

Thanks a lot !

  • 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-03T17:09:50+00:00Added an answer on June 3, 2026 at 5:09 pm

    The idea is that you ask for a new object to be created inside a context and then you use it:

    Actualite* actu = [NSEntityDescription insertNewObjectForEntityForName:@"Actualite" inManagedObjectContext:managedObjectContext];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

would like to know how can this be implemented in Joomla. I have a
This is possibly a candidate for a one-line answer. I would like know it
Would like to know what does Drupal 7 and Acquia have in common? I
I would like know how I could simplify(modify) the hSelecVarIndCallback function. I want to
I would like know if it is possible to create embedding of audio message
I would like to know if anybody knows if it is possible to drag
I would like know what is the best possible way to implement transactions with
Would like to know when to use, This applies for what browser ? if
I would like to know which dependency described in my pom.xml brings a transitive
Would like to know how it is possible to rewrite www.site.com/?lang=de to www.site.com/de in

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.