I’ve been really embellishing on the Homepwnr app to learn about digging through the documentation on adding features I think Homepwner should have it where a real world app. I’ve successfully added a large image view controller that pushes onto the navstack to show the image full screen when the image is tapped in itemDetailViewController, added the ability to add new asset types, fixed a nice little swiping system for editing existing asset types(Swipe left to rename an asset and the row label is replaced with a textfield, swipe right to delete an asset type). Now I’d like to sort the tableview in itemsViewController into sections based on asset types. I need some help populating my data structure for this though.
Here is how I’ll model my table view controller:
NSArray for table sections
each section in the array will be an NSDictionary with 2 keys, @“Header” - which will be the Asset Type, and @“Possessions” which is an array of possessions of that asset type.
I can handle building my table view from this structure no problem. Where I am stumped is how do I take advantage of the to many relationship that asset types have to possessions. How do I get my Asset Types possessions into an array? Do I need to make a fetch request with a predicate to fetch possessions that have the matching asset type, or is there a simpler way? Is the to many relationship “possessions” of AssetType entity an accessible property of the AssetType entity? If so how do I access it? What does it return? I am appreciative for any help offered.