Objective c SKCloudServiceController.requestAuthorization在授权时被卡住

Objective c SKCloudServiceController.requestAuthorization在授权时被卡住,objective-c,swift,xcode,controller,apple-musickit,Objective C,Swift,Xcode,Controller,Apple Musickit,我指的是以下SKCloudServiceController.requestAuthorization方法。一旦状态被授权,我想更新@State var showStart=false,以便将视图推送到下一个视图 if (showStart) { NavigationLink(destination: Main(), isActive: $showStart) { EmptyView() }.hidden() } SKC

我指的是以下
SKCloudServiceController.requestAuthorization
方法。一旦状态被授权,我想更新
@State var showStart=false
,以便将视图推送到下一个视图

  if (showStart) {
        NavigationLink(destination: Main(), isActive: $showStart) {
            EmptyView()
        }.hidden()
    }
    SKCloudServiceController.requestAuthorization { (status) in
        if status == .authorized {
            print(AppleMusicAPI().fetchStorefrontID())
            showStart = true
        }
    }

但是,在该操作运行且状态被授权后,应用程序将冻结且不会更改showStart。

通过实现以下功能进行修复。它允许
SKCloudServiceController.requestAuthorization
完成,然后在完成后,将
showStart
设置为true

func requestAccess(_ completion: @escaping(Bool) -> Void) {
    SKCloudServiceController.requestAuthorization { (status) in
        switch status {
        case .authorized:
            completion(true)
        case .denied, .notDetermined, .restricted:
            completion(false)
        @unknown default:
            completion(false)
        }
    }
}
requestAccess { (true) in
    showStart = true
}

通过改为实现以下函数进行修复。它允许
SKCloudServiceController.requestAuthorization
完成,然后在完成后,将
showStart
设置为true

func requestAccess(_ completion: @escaping(Bool) -> Void) {
    SKCloudServiceController.requestAuthorization { (status) in
        switch status {
        case .authorized:
            completion(true)
        case .denied, .notDetermined, .restricted:
            completion(false)
        @unknown default:
            completion(false)
        }
    }
}
requestAccess { (true) in
    showStart = true
}