我不知道这段代码有什么问题,它总是向我显示这个东西: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]
}
})
}