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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:06:26+00:00 2026-06-14T13:06:26+00:00

When I create an entity using core data then generate a subclass of NSManagedObject

  • 0

When I create an entity using core data then generate a subclass of NSManagedObject from it I get the following output (in the .h):

@class Foo;

@interface Foo : NSManagedObject

@property (nonatomic, retain) NSString *name;
@property (nonatomic, retain) NSSet *otherValues;

@end

However, in my .m file I want to make use of the name and otherValues values. Normally I would simply create a couple of ivars and then add the properties for them as I required. That way I can access them in my .m file easily.

In this situation would it be acceptable to do this? Would adding ivars to the .h (for name and otherValues) cause any unusual behaviour in the persistance & retrieval of 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-14T13:06:27+00:00Added an answer on June 14, 2026 at 1:06 pm

    You don’t use instance variable to access attributes of Core Data managed objects.

    The generated implementation file contains the statements

    @dynamic name;
    @dynamic otherValues;
    

    which means that the getter/setter functions for the Core Data properties are created dynamically, e.g. to retrieve the value from the managed object context or from the underlying persistent store.

    So you should always use the properties to access the attributes, for example:

    Foo *myFoo = [NSEntityDescription insertNewObjectForEntityForName:@"Foo" inManagedObjectContext:context];
    myFoo.name = @"test";
    

    Alternatively, you can use the key-value methods:

    [myFoo setValue:@"test" forKey:@"name"];
    

    See also: Modeled Properties in the “Core Data Programming Guide”:

    Core Data dynamically generates efficient public and primitive get and
    set attribute accessor methods … In a managed object sub-class, you
    can declare the properties for modeled attributes in the interface
    file, but you don’t declare instance variables.

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

Sidebar

Related Questions

I'm studying using Core Data. After I create the entity in Xcode, I want
I'm developing an iOS app using Core Data. And I have a Log entity
I have an custom class for an Core Data entity, called 'Friends'. As I
Exactly as the title says, why does Core Data create instances of NSManagedObject with
Hi I have created an array from core-data using: NSArray* invoiceItem =[fetchedResultsController fetchedObjects]; which
I am trying to create a new Core Data entity and copy [some of]
I'm trying to use a view to create an ADO.NET entity using a view.
When using Entity Framework Code First 4.3.1 it is possible to create relationships with
I am using the Entity Framework just to create classes that can be mapped
currently i create dynamic database using CreateDatabase() method in Entity Framework. it executes sucessfully

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.