iOS 10请求授权

时间:2017-02-22 17:25:48

标签: swift3 ios10 mpmedialibrary

我不知道这段代码有什么问题,它总是告诉我这件事: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]
                }
            })
        }

0 个答案:

没有答案