I have an entity Product which has relationship category, which is optional, and use nullify as the delete rule.
In order to list the products by category, I put sectionnamekeypath to be category.name of the Product in the NSFetchedResultsController.
The table listing looks fine. Products with no category filled in are listed in a section with blank heading. However, there are 2 problems:
1) In the console, error msg appears:
CoreData: error: (NSFetchedResultsController) A section returned nil value for section name key path ‘category.name’. Objects will be placed in unnamed section
Will this error msg cause problem in production environment?
2) When category with non-empty product is deleted, the products are now having category.name = nil, and is not listed under the blank heading section automatically. I need to do a reloadData to make it appear. Is there any other way to solve this problem?
Or, should I avoid this problem altogether by automatically attaching a product to a special “unclassifed” category when it doesn’t have any category assigned to it? But then when category with non-empty product in it is deleted, I have to load its associated products and mark them as “unclassified” category, instead of just nullify. It sounds like quite a lot of special handling needed.
Does anyone have similar experience? How would you handle it?
Finally I found this question which is similar to my problem, and now problem solved.