I have an array of Business objects. Each Business object contains an array of key-value pairs, one element of which can be a nested array of ContentBlocks objects.
var masterArray = [
Business(busName: "Dave's Cafe", busId: 1, website: "http://www.davescafe.com", latLong: (45.541, -45.609),
actions: [["title": "About Us", "contentId": "123", "actionType": "content"],
["title": "Website", "url": "http://www.davescafe.com", "actionType": "web"]],
contentBlocks:[
ContentBlock(busName: "Dave's Cafe", busId: 1, contentId: "123", title: "Testola!", body: "Hello there!")
]),
Business(busName:...
]
I can filter the array to return a specific Businesses matching a unique busId by using something like this:
let rtnArray = masterArray.filter{$0.busId == id}
if rtnArray.count == 1{
return rtnArray[0]
} else {
return // feedback that no matches were found
}
Additionally, I'd like to return a specific contentBlock by filtering on the unique contentId (if necessary I can also pass the busId of the Business 'owner'). I'm really struggling to move forward so any pointers in the right direction would be great.