How can I search the iPod Library in the same manner as the iOS Music application? I want to make general queries that return results for each Artists, Albums, and Songs. Fo
Swift 3+ solution for filtering items after running the query, similar to Mohammed Habib's answer:
let searchString = “string to search”
let query = MPMediaQuery()
let filteredItems = query.items?.filter { item -> Bool in
let properties = [item.songTitle,
item.artist,
item.albumTitle]
let lowercasedProperties = properties.compactMap { $0.lowercased() }
return lowercasedProperties.contains(searchString.lowercased())
}
print(filteredItems ?? [])