Closed jmalla closed 2 years ago
Got it working. Need to do this:
var dataService: ESPMContainer<OfflineODataProvider>? {
guard let odataController = OnboardingSessionManager
.shared
.onboardingSession?
.odataControllers[ODataContainerType.eSPMContainer.description] as? ESPMContainerOfflineODataController else {
AlertHelper.displayAlert(with: "OData service is not reachable, please onboard again.", error: nil, viewController: self)
return nil
}
return odataController.dataService
}
All the other errors disappeared after that.
Tutorials: https://developers.sap.com/tutorials/fiori-ios-scpms-starter-mission-02.html
Write here how you think we can improve the tutorial ...
I had issues in Step 5 Load customer and product data
I copied over the code from GitHub: ` /* First you define a DataQuery to perform an expand for the customer's sales orders. This data query object you can simply pass into the fetchCustomers(:) method call. Handle the errors and display an Alert Dialogue to the user. Using a DispatchGroup allows us to sequentially run background tasks and perform a certain action as soon as all tasks are completed. First you enter the group and you have to leave the group in any place where you return out of the block. In case you retrieve data from the backend sort the customers by the amount of sales orders they have and set them to the array. / private func fetchCustomers(_ group: DispatchGroup) { group.enter()
Here are the errors:
With Line 91: dataService?.fetchCustomers(matching: query) { [weak self] result, error in
Here are the errors Error: Unable to infer type of a closure parameter 'error' in the current context Error: Unable to infer type of a closure parameter 'result' in the current context
With line 99: self?.customers.append(contentsOf: result!.sorted(by: { $0.salesOrders.count > $1.salesOrders.count })) Error: Generic parameter 'S' could not be inferred
With line 112: Error: dataService?.fetchProducts() { [weak self] result, error in
Here is my complete code. Can you please take look: `// // OverviewTableViewController.swift // TutorialApp // // Created by Jay Malla on 10/28/22. // Copyright © 2022 SAP. All rights reserved. //
import UIKit import SAPFiori import SAPFoundation import SAPOData import SAPOfflineOData import SAPFioriFlows import SAPCommon import ESPMContainerFmwk import SharedFmwk
class OverviewTableViewController : UITableViewController , SAPFioriLoadingIndicator { var loadingIndicator: FUILoadingIndicatorView?
}
extension OverviewTableViewController: UICollectionViewDelegate { //TODO: Implement navigation }
extension OverviewTableViewController: UICollectionViewDataSource { func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { return customers.count }
} `
Thanks for your help.
Jay