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

  • Home
  • SEARCH
  • 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 3967678
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T03:44:55+00:00 2026-05-20T03:44:55+00:00

I am writing a Mac app that uses Core Data as its persistence layer,

  • 0

I am writing a Mac app that uses Core Data as its persistence layer, and am curious as to what the general consensus is with the “ownership” of searches.

Let’s say that I have a class called Recipe (generated subclass of NSManagedObject) and I would like to be able to search for, say, “Recipes containing a certain ingredient”, “Recipes that can feed more than 4 people”, and so on. I can conceive methods like:

-(NSArray *)fetchRecipesContaining:(Ingredient *)ingredient;
-(NSArray *)fetchRecipesFeedingMorePeopleThan:(int)count;

and the implementation knows how to construct an appropriate NSFetchRequest/NSPredicate to go get them. The question is what object normally implements these methods? In a Java world, these would often live in an instance method on a RecipeFactory. I can also see the case for a class method in the Recipe class.

In a Hello World application (which most tutorials seem to offer) the logic is embedded directly in the invoking code, however, I am not that keen on having boilerplate code dealing with NSFetchRequests and NSEntityDescriptions scatted all through the invoking code. I really would prefer to abstract that logic away and allow a more meaningful API (per above) for fetching objects.

I am inclining towards a class method on Recipe (and implemented using categories so that I don’t have to modify the generated classes), but wanted to throw it out there and see what other Core Data users might use.

Thanks.

  • 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-20T03:44:55+00:00Added an answer on May 20, 2026 at 3:44 am

    Use categories. As you note, this leaves the Xcode-generated classes untouched while allowing you to extend the functionality of the managed object class.

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

Sidebar

Related Questions

I'm writing an app that heavily uses OpenGL; either on the Mac or on
I am writing a mac application that uses the scripting bridge to control iTunes.
I am writing an app that downloads a wav file from a server and
I'm currently writing a small python app that embeds cherrypy and django using py2app.
Interested in writing an iPhone app but don't want to buy a mac or
I'm new to building application on Mac. I have global data that I need
I'm writing an app for Android that spawns a service that periodically checks the
I'm totally new to Mac OS and iPhone and I'm writing some small app.
I'm writing a program (for Mac OS X, using Objective-C) and I need to
I am writing a text editor for Mac OS X. I need to display

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.