Reputation: 11
I am following the tutorial provided by SAP to create an app in SwiftUI that present data of customers in a list. Link to the tutorial: https://www.youtube.com/watch?v=eu9ElMcUtCI&t=480s
The App is loading correctly, then I have the following error:
Unexpectedly found nil while unwrapping an Optional value
This happen in the URL reference where I set the destination:
let odataController = appDelegate.sessionManager.onboardingSession?.odataControllers[destinations["com.sap.edm.sampleservice.v2"] as! String] as? ESPMContainerOfflineODataController
Any idea on how to create a walk around with the SAP ID ? In the tutorial, it worked, so something looks deprecated on SAP SDK side side.
Here is the full code:
` class ApplicationUIManager: ApplicationUIManaging { // MARK: – Properties
let window: UIWindow
var isOnboarding = false
private var coveringViews = [UIView]()
// MARK: – Init
public init(window: UIWindow) {
self.window = window
}
// MARK: - ApplicationUIManaging
func hideApplicationScreen(completionHandler: @escaping (Error?) -> Void) {
// Check whether the covering screen is already presented or not
guard isSplashPresented == false else {
completionHandler(nil)
return
}
coverAppScreen(with: UIViewController().view)
completionHandler(nil)
}
func showSplashScreenForOnboarding(completionHandler: @escaping (Error?) -> Void) {
// splash already presented
guard isSplashPresented == false else {
completionHandler(nil)
return
}
setupSplashScreen()
completionHandler(nil)
}
func showSplashScreenForUnlock(completionHandler: @escaping (Error?) -> Void) {
guard isSplashPresented == false else {
completionHandler(nil)
return
}
setupSplashScreen()
completionHandler(nil)
}
func showApplicationScreen(completionHandler: @escaping (Error?) -> Void) {
guard isSplashPresented else {
completionHandler(nil)
return
}
let appDelegate = (UIApplication.shared.delegate as! AppDelegate)
let appViewController: UIViewController
var mainView = MainView()
let hostingController = UIHostingController(rootView: mainView)
appViewController = hostingController
isOnboarding = false
let destinations = FileConfigurationProvider("AppParameters").provideConfiguration().configuration ["Destinations"] as! NSDictionary
let odataController = appDelegate.sessionManager.onboardingSession?.odataControllers[destinations["com.sap.edm.sampleservice.v2"] as! String] as? ESPMContainerOfflineODataController
mainView.espmContainer = odataController?.dataService
window.rootViewController = appViewController
removeCoveringViews()
// if isOnboarding {
// let appDelegate = (UIApplication.shared.delegate as! AppDelegate)
// coveringViews.removeAll()
// maintain this boolean since no splash screen is present now
// } else {
// }
completionHandler(nil)
}
func releaseRootFromMemory() {
guard isOnboarding == false else {
return
}
window.rootViewController = FUIInfoViewController.createSplashScreenInstanceFromStoryboard()
isSplashPresented = false
isOnboarding = true
}
// MARK: – Helpers
private var isSplashPresented: Bool = false
private func setupSplashScreen() {
let splashViewController = FUIInfoViewController.createSplashScreenInstanceFromStoryboard()
coverAppScreen(with: splashViewController.view)
// Set the splash screen for the specific presenter
let modalPresenter = OnboardingFlowProvider.modalUIViewControllerPresenter
if let rootVc = window.rootViewController as? FUIInfoViewController {
modalPresenter.setSplashScreen(rootVc)
} else {
// should never happen but adding as a fail safe
modalPresenter.setSplashScreen(splashViewController)
}
modalPresenter.animated = true
}
// Hide the application screen by adding a view to the top
private func coverAppScreen(with view: UIView?) {
guard let view = view else {
return
}
// always hide the topViewController's screen
if let rootVc = UIApplication.shared.topViewController() {
view.frame = rootVc.view.bounds
rootVc.view.addSubview(view)
coveringViews.append(view)
isSplashPresented = true
}
}
// Remove covering views when no more required
private func removeCoveringViews() {
_ = coveringViews.map { $0.removeFromSuperview() }
isSplashPresented = false
}
}`
I am trying to present a list of random customers from the SAP SDK based on their tutorial, I expected to be able to present a list in my simulator.
Upvotes: 1
Views: 16