iPhoneCoreDataRecipes Explained…

Im going thru this Apple app and im noting my progress in understanding it.  Any comments are appreciated.

black = unanswered questions

red = my answers so far

blue = partially answered on the blog itself

green = less important, design questions maybe…

RecipeListTableViewController.m
1) Why @class Recipe and @class RecipeTableViewCell
2)  They adopt a RecipeAddDelegate & NSFetchedResultsControllerDelegate protocols? YES…Ive never seen a protocol before.  I guess the NSFRC protocol class is a UIKit class but i had never seen a customcreated class be used as a protocol…COOL!
3)  Why do we declare showRecipe & configureCell methods but not the add:method or the whole bunch of others….
4)  When creating RecipeAddViewController, we do addController.delegate = self…what does this mean really?
5)  We then create a blank recipe object and set the addController.recipe = newRecipe…what is this really doing?  telling it that whatever newRecipe is created, set it to what?
6)  What does recipeAddViewController: method do?  it shows the recipe via the showRecipe method…?Its a RecipeAddViewController <protocol> method, so i just mosied on over to that code and saw that saves (or cancels) the recipe to the psc from the moc, right?
7)  The showRecipe method creates a RecipeDetailViewController and pushes it onto the stack for show. This method takes the recipe name that we created in the modalVC and sets it to the newly created RecipeDetailViewController’s recipe ivar.  This confuses me a bit cause the RecipeDetailViewController like the RecipeListTableViewControllers have no xibs.  The detailVC is actually composed of the DetailHeaderView.xib, a navcontroller which i can only assume is the one from the modalview and some other one at the bottom which i have not found yet.  Furthermore, we had set the addController.delegate =self and the addController.recipe = recipe and now we are setting detailViewController.recipe = recipe.  I understand why (we went from a modal temporary addController to a more permanent detailViewController, so all we are doing is passing the name input by the user from one to the next and storing it to the psc just in case no other data is added.
8)  numberOfSectionsInTableView calls a NSFRC method called sections just to set the count to at least 1 (is this what the NSFRCDelegate protocol called?
9)  numberOfRowsInSection calls id<NSFetchedResultsSectionInfo> … this is new but basically it returns a value for the numberOfObjects in the RC
0)  the whole RecipeTableViewCell *recipeCell is weird but ill compare it to the code in a normal section of cellForRowAtIndexPath, i bet its similar. I compared it to a regular cellForRowAtIndexPath and its exactly the same, it just switches wording.  And at the end, instead of calling the cell.textLabel.text = @”some value” it calls a method, self.configureCell passing it the recipeCell and indexPath arguments so that this other method configures that part. Im not sure why its split up like this though?
1)  configureCell actually sets the recipe to the cell.  so why make a separate function for it?
2)  didSelectRowAtIndexPath creates a recipe object and assigns it the current rowAtIndexPath value?  And then cals the showRecipe method?  I dont get this, why does it call the NSFRC and add it to a Recipe?  Its the same code the cFRAIP called.
3)  commitEditingStyle DELETE i get…but then i dont because another delete is called in tableview changedContents…
4)  fetchedResultsController is the method otherwise found in the appDelegate or FlickrFetcher singleton in our Paparazzi case….
5)  if nil, create fetchRequest, for said Entity, create sort, apply sort parameter, create aFRC with that request, set delegate to self?, set self.fetchedResultsController to aFRC, cleanup and then return the fetchedResultsController…but this doesnt execute it right?  it gets executed in the viewDidLoad right? but what does the sectionNameKeyPath part do?  And again this code of setting the object.delegate = self and then this time it adds self.fetchedResultsController = aFetchedResultsController?
6)  controllerWillChangeContent is a notification
7)  didChangeObject CHANGEINSERT is for when the user decides to insert a new recipe, CHANGEDELETE for when user decides to delete a recipe (but i thought we had this already), CHANGEUPDATE is for when we update a recipe and CHANGEMOVE is for when we move it in the tableview from a lower or higher indexpath…
8)  then there is controller:didChangeSection with CHANGEINSERT and CHANGEDELETE…what does this do?

Leave a Reply