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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:41:52+00:00 2026-05-26T12:41:52+00:00

I’ve read many of the SO questions on NSManagedObject, the Apple docs, and more,

  • 0

I’ve read many of the SO questions on NSManagedObject, the Apple docs, and more, but I still don’t really get what subclassing NSManagedObject is for – what role does it play?

In the Apple docs it talks about how I can’t override a bunch of methods, shouldn’t use custom instance variables, blah and blah (I don’t understand some of it yet), and so forth – so what can I do with NSManagedObject? What are the restrictions, must-follow guidelines, and what aren’t restrictions?

I’m trying to make a little box drawing program to learn Core Data, and I’m thinking of adding “draw” methods to a subclass of NSManagedObject so that a view can just tell them to draw for itself – is this permitted?

So, my question in one sentence would be, what’s the “real” difference between subclassing NSManagedObject and any other class – what does Core Data do with it?

If this is too broad, I’ll try to narrow my question down or something.

  • 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-05-26T12:41:53+00:00Added an answer on May 26, 2026 at 12:41 pm

    I still don’t really get what subclassing NSManagedObject is for – what role does it play?

    Convenience for the developer – in terms of CodeSense, shorter syntax, and some compile-time checks that help thwart misspellings of keys.

    so what can I do with NSManagedObject? What are the restrictions, must-follow guidelines, and what aren’t restrictions?

    The UI built into Xcode will make the NSManagedObject subclasses for you – you really don’t need to do it by hand – but, basically, they are just NSManagedObjects with some properties tacked on. Instead of using @synthesize or such, you use @dynamic and Apple takes care of the rest for you – hooking up those properties to getters/setters which mimic what you would normally do with a “bare” NSManagedObject.

    I’m trying to make a little box drawing program to learn Core Data, and I’m thinking of adding “draw” methods to a subclass of NSManagedObject so that a view can just tell them to draw for itself – is this permitted?

    You could…. but I wouldn’t. This sounds like bad design – try to keep your Model and Controllers separate.

    Model objects shouldn’t contain business logic / drawing code. Use the model simply as the “state” of your application. Make something else responsible for the drawing. Plus, while I can’t say this with absolute authority, I believe there is some overhead if you’re dealing with updating / retrieving info from an NSManagedObject.

    (Basically, it’s like dealing with an NSDictionary… sorta. It’s less efficient to grab items out of a dictionary than it is to access an ivar.)

    For an app that does things like drawing – you’ll probably want to avoid that overhead by making a structure for your in-memory things, and possibly a second, similar structure for persistence/serialization (like to CoreData).

    So, my question in one sentence would be, what’s the “real” difference
    between subclassing NSManagedObject and any other class – what does
    Core Data do with it?

    I would say – don’t subclass NSManagedObject by hand at all – use what Xcode gives you. If you want more (other than maybe a custom constructor) then you’re probably barking up the wrong tree.

    EDIT:

    I think there might have been some confusion about what I meant when I said “don’t subclass NSManagedObject by hand at all”

    To elaborate, and incorporate one of the responses:

    Start with the data model designer in Xcode, create your models, and use the following menu option:

    enter image description here

    Then, you could modify the generated class to include custom:

    • Constructors
    • Data Conversion Methods
    • Validation
    • Formatting
    • Sort Descriptors
    • Filters

    If your use case doesn’t fit in that list, you should really seriously think about putting it somewhere else (as in your example with the “Draw” method).

    All of those things mentioned above could be tacked on to an NSManagedObject subclass which was created for us by Xcode (we didn’t create “by hand”) – and they all revolve around dealing with the data directly (formats / conversions / etc) and/or around pulling the data out of Core Data (filters / sorting).

    They don’t add iVars, they don’t perform any complicated operations outside of the scope of data storage and retrieval.

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

Sidebar

Related Questions

I want to count how many characters a certain string has in PHP, but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
I know there's a lot of other questions out there that deal with this
I don't have much knowledge about the IPv6 protocol, so sorry if the question
Seemingly simple, but I cannot find anything relevant on the web. What is the

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.