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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T12:08:46+00:00 2026-05-15T12:08:46+00:00

Writing my first app with CoreData. The book I’m using to guide me has

  • 0

Writing my first app with CoreData. The book I’m using to guide me has code like this:

// 'Person' is my managed object class
Person *newPerson = [NSEntityDescription
  insertNewObjectForEntityForName:@"Person"
  inManagedObjectContext:self.managedObjectContext];

[newPerson setValue:nameField.text forKey:@"name"];

The book says that using the property style, e.g.

newPerson.name = nameField.text;

also works, but that “it is very common to see Core Data code use the KVC Approach”

To me, I can’t see one reason to use the KVC approach; magic strings just beg for runtime errors and it’s a lot more typing.

That being said, I’d like to learn my habits now regarding the “iPhone Way” of doing things.

Is there a difference in these approaches and, if most people use the first, KVC, approach…why?

  • 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-15T12:08:46+00:00Added an answer on May 15, 2026 at 12:08 pm

    Most people do not use the KVC approach I have seen; I do not, for the reasons you describe.

    To save your sanity, use Mogenerator to build your accessors:

    http://rentzsch.github.com/mogenerator/

    It’s a command line tool that generates proxy objects that you can use to fetch CoreData objects, with some convenience methods – but even better, some category overlays that you can add your own methods to that will not be destroyed when you re-generate classes from your data model.

    XCode can also generate data objects from your model but the classes are more simple (just accessors), and mogenerator is I think easier to use repeatedly (which is important since you will tend to change the model a lot over time). Perhaps the next XCode will be better in that regard.

    I usually generate all data model classes into a subdirectory under Classes called “DataObjects” – then you can just re-add that whole directory every time you regenerate classes from the data model that leads to new classes being created (when you have new entities). A sample command line run looks like:

     mogenerator -m ../MyProject.xcdatamodeld/MyProject-v1.xcdatamodel
    

    which will generate classes into the current directory from the given data model (in that case I have a versioned model with just the first version).

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

Sidebar

Related Questions

I'm writing my first PHP app that has to directly deal with dates, and
I'm writing my first Windows CE app using the .NET Compact Framework v3.5. I
I'm writing my first desktop app and I'm struggling with class instances. This app
I'm writing my first 2D app for Android using OpenGL. I'm writing it on
I'm writing my first app with ASP.NET MVP (attempting Supervisory Controller) and Unit Testing
I'm writing my first Perl app -- an AOL Instant Messenger bot that talks
I'm writing my first iPhone app, so I haven't gotten around to figuring out
Sorry for the slightly noobish question, as I am writing my first rails app.
I writing a C# App for a customer for the first time and I
I am writing my first serious wxWidgets program. I'd like to use the wxConfig

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.