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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:28:27+00:00 2026-06-13T02:28:27+00:00

I have a simple custom object (Ingredient) with instance variables, class methods, and instance

  • 0

I have a simple custom object (“Ingredient”) with instance variables, class methods, and instance methods. This custom object is inexorably entwined throughout my application. I want to store instances of this custom object using Core Data. From what I have read, having instance variables and methods in managed objects are discouraged.

So now I’m confused on how to proceed.

From examples of similar situations, it seems that it is common practice to fetch the results and put it in an array like so:

NSMutableArray *array = [managedObjectContext executeFetchRequest:fetchRequest error:&error];

But I am unclear what I can do with the mutableArray of objects. Can I do all the things I want to do currently with my custom object: modify instance variables, send the object to methods, etc?

Or do I create a “ArchivedIngredient” managed object with attributes matching my “Ingredient” instance variables, using my “Ingredient” object as I currently do – then convert “Ingredient” back to a “ArchivedIngredient” object when I need it stored? If so, how would that be done?

What am I missing here?

  • 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-13T02:28:28+00:00Added an answer on June 13, 2026 at 2:28 am

    From what I have read, having instance variables and methods in managed objects are discouraged.

    I do not now what you mean by this, but if what you mean is that you are not supposed to create classes based on your core data entity, you are wrong. You can use the core data inspector to assign a custom class to your entity, and create the header and source file of the implementation of that class by selecting the entity on your model, and using Xcode’s product menu to find “Create NSManagedObject Subclass”. This will generate your NSManagedObject subclass. You can add instance method and class method, just like other classes.

    When you modify a property of your custom class, and you wish to save these changes, you need to get the managed object context you used to fetch the object and call the save method. This will put the changes in the persistent store.

    Also, note that the method you are calling “executeFetchRequest” does NOT return a mutable array. It returns a immutable subclass of NSArray, which you must treat as an NSArray.

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

Sidebar

Related Questions

I have the following methods in my simple Custom Parser Class, when I execute
I have a class where I want 'each' to yield another custom object, so
I have a simple custom NumberField: class NumberInput(forms.widgets.Input): input_type = 'number' class NumberField(forms.DecimalField): def
i'm missing something fundamental here. i have a very simple custom class that draws
I have the following lines in my ~/.emacs.d/init.el (custom-set-variables '(flymake-allowed-file-name-masks (quote ( (\\.cc\\' flymake-simple-make-init)
I have an simple custom object called MyObject (a couple of basic properties and
I'm writing a plug-in for an application where I have a custom class that
I have made a very simple custom object pictureData . Here is the .h
I have a simple custom Point class as follows and I would like to
I have a simple console application that is designed to read a custom Configuration

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.