我不知道这段代码有什么问题,它总是告诉我这件事:fatal error: unexpectedly found nil while unwrapping an Optional value
当我尝试访问MPMediaLibrary
时,我得到了这个东西,代码就是这样:
if (MPMediaLibrary.authorizationStatus() == MPMediaLibraryAuthorizationStatus.notDetermined) {
// Access has not been determined.
MPMediaLibrary.requestAuthorization({ (status: MPMediaLibraryAuthorizationStatus) in
if (status == MPMediaLibraryAuthorizationStatus.authorized) {
let albumsQuery: MPMediaQuery = MPMediaQuery.albums()
let albumItems: [MPMediaItemCollection] = self.albumsQuery.collections! as [MPMediaItemCollection]
}
})
}