I'm working a tutorial from https://www.raywenderlich.com/921-cocoa-bindings-on-macos. I'm wondering what the .enumerated() and .map() functions are operating on in this section:
@IBAction func searchClicked(_ sender: Any) {
guard let resultsNumber = Int(numberResultsComboBox.stringValue)
else {
return
}
iTunesRequestManager.getSearchResults(searchTextField.stringValue, results: resultsNumber, langString: "en_us") { (results, error) in
let itunesResults = results.map {
return Result(dictionary: $0)
}
.enumerated()
.map({ (index, element) -> Result in
element.rank = index + 1
return element
})
DispatchQueue.main.async {
self.searchResultsController.content = itunesResults
print(self.searchResultsController.content!)
}
}
}
I can usually figure out most things eventually in Swift but I'm stumped here and the explanatory text isn't clear to me either. I hope someone can help me understand this part of the tutorial. Thanks!