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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T03:29:30+00:00 2026-06-19T03:29:30+00:00

I am using Core Data to save some strings. I have the following class

  • 0

I am using Core Data to save some strings. I have the following class called Results

Results.h

#import <CoreData/CoreData.h>

@interface Results : NSManagedObject

@property(nonatomic, retain) NSString *lessondate;
@property(nonatomic, retain) NSString *lesson;
@property(nonatomic, retain) NSString *location;
@property(nonatomic, retain) NSString *start;
@property(nonatomic, retain) NSString *end;

@end

Results.m

#import "Results.h"

@implementation Results

@dynamic lessondate;
@dynamic lesson;
@dynamic location;
@dynamic start;
@dynamic end;

@end

The following is my code to perform the save:

-(void)saveLesson{

Results *result = (Results *)[NSEntityDescription insertNewObjectForEntityForName:@"Diary" inManagedObjectContext:managedObjectContext];

result.lessondate = calendarDateString;
result.lesson = [NSString stringWithFormat:@"%@", lessonText.text];
result.location = [NSString stringWithFormat:@"%@", locationTest.text];
result.start = [NSString stringWithFormat:@"%@", startTimeText.text];
result.end = [NSString stringWithFormat:@"%@", endTimeText.text];
NSError *error;


// here's where the actual save happens, and if it doesn't we print something out to the console
if (![managedObjectContext save:&error])
{
    NSLog(@"Problem saving: %@", [error localizedDescription]);
}


[self dismissViewControllerAnimated:YES completion:nil];

}

But when I try to save the data in the app, the app crashed and shows these errors

2013-02-18 11:46:25.705 After managedObjectContext: <NSManagedObjectContext: 0x1f892480>

2013-02-18 11:46:33.762 -[NSManagedObject setLesson:]: unrecognized selector sent to instance 0x1f80b380

2013-02-18 11:46:33.764  *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSManagedObject setLesson:]: unrecognized selector sent to instance 0x1f80b380'

Can someone please tell me why this is crashing? The exact same code is in another app and that works fine.

  • 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-19T03:29:32+00:00Added an answer on June 19, 2026 at 3:29 am

    You are creating an entity different from what you expect.

    You are calling

    [NSEntityDescription insertNewObjectForEntityForName:@"Diary"
                                  inManagedObjectContext:managedObjectContext];
    

    which creates entity Diary. Put @"Results" as a first argument for the method.

    While you are assigning the created Diary entity into a Results object, it is only a syntactic sugar—the real object underneath is what you have passed as an entity name.
    Diary object doesn’t have the lesson property, and you get the exception.

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

Sidebar

Related Questions

I need some understanding about using Core Data. Can it be used to save
I'm using core data to save some integer (rate) and then I call save
Using core data I'd like to fetch some data. My model uses some abstract
I am using core data to store some details. But when I run my
I'm using Core Data to locally persist results from a Web Services call. The
I'm using core data in my app. I have two entities that are related:
I'm using Core Data to persist some information in a SQLite database. I'm testing
I have an App using core data with 3 entities with very similar attributes.
Inputing a JSON file into Core Data using the following code I found on
I started using core data and I read that I can save the data

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.