Good afternoon! Please tell me how to load the usdz model from the url link (https) in AR Quick Look, I am using the code from the listing of the Apple presentation, and I get an error "Fatal error: Unexpectedly found nil while unwrapping an Optional value", what am I doing wrong? I hope and really look forward to your reply. The application compiles correctly, the error occurs after pressing a button on the device itself.
import UIKit
import QuickLook
import ARKit
import RealityKit
class ViewController: UIViewController, QLPreviewControllerDataSource {
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func startDecoratingButtonPressed(_ sender: Any) {
let previewController = QLPreviewController()
previewController.dataSource = self
present(previewController, animated: true, completion: nil)
}
func numberOfPreviewItems(in controller: QLPreviewController) -> Int { return 1 }
func previewController(_ controller: QLPreviewController, previewItemAt index: Int) -> QLPreviewItem {
let fileUrl = Bundle.main.url(forResource: "toy_drummer", withExtension: "usdz")!
let previewItem = ARQuickLookPreviewItem(fileAt: fileUrl)
previewItem.canonicalWebPageURL = URL(string: "https://developer.apple.com/augmented-reality/quick-look/models/drummertoy/")
previewItem.allowsContentScaling = false
return previewItem
}
}