Core Data Graphical Fetch Requests?

Discussion in 'iOS Programming' started by ArtOfWarfare, Jul 7, 2013.

  1. ArtOfWarfare, Jul 7, 2013
    Last edited: Jul 7, 2013

    ArtOfWarfare macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #1
    I just discovered the Fetch Requests section of the Core Data graphical editor and it looks like it could be a great asset in keeping my project organized.

    I have two problems though:

    1 - I can't find the documentation on how to use it anywhere. All of the documentation I can find from google searches combining the various terms "Core Data", "Graphical", and "Fetch Requests" just turn up documentation on either how to use the entities, attributes, and relationships section of the graphical editor, or how to programmatically write fetch requests.

    2 - How do I use the fetch request that I put together in my Core Data model inside of my code? I'd like to assign this fetch request to an NSFetchedResultsController.

    And on an only partially related note, what is the "Configurations" section of the Core Data model editor? Does anyone have examples on how to use it or how it's useful? (I just figure while I'm learning more about the Core Data editor I may as well ask about all the parts of it I don't understand / I've never used before.)

    Edit:

    Okay, I'm not sure if this is the best way of doing it, but I've found that NSManagedObjectModel has a method fetchRequestTemplateForName: which seems to accomplish #2. Note that the method seems to return an immutable NSFetchRequest of sorts, so you have to make a copy of it first.
     
  2. MattInOz macrumors 68030

    MattInOz

    Joined:
    Jan 19, 2006
    Location:
    Sydney
    #2
    This is the only documentation I've ever found for model fetchRequests

    Core Data Programming Guide

    Basically as you said you either pull the fetchrequest from the model then copy to mutate. There is another method that lets you pass a dictionary of variables to mutate the request before it's passed to you.

    It's always seemed like a highly useful thing but I've seen very few core data tutorials or guides that use it. So I wonder if there is something wrong with it.
     

Share This Page