我正在尝试从swift中的音乐应用中检索用户的播放列表名称。
我这样试试
let myMediaQuery = MPMediaQuery.playlists().collections
虽然How to retrieve Playlist from iPod Library in iOS?似乎有答案,但它在Swift中不起作用
答案 0 :(得分:4)
let myPlaylistsQuery = MPMediaQuery.playlists()
let playlists = myPlaylistsQuery.collections
for playlist in playlists! {
print(playlist.value(forProperty: MPMediaPlaylistPropertyName) ?? "No name")
}
这应该有效