'how to get data from api response to display on label in swift
I am trying to get API data to display in label i get api response successfully in model, how i can get response values in viewcontroller to show on label. here is the method to get json response
private textCode:CodeModel
private func load() {
codeProvider.load(target: .myCode, withActivity: true) {[weak self] result in
switch result {
case .success(let response):
print(response,"response here")
self?.textCode = response
self?.output.perform(action: .didLoad)
case .failure(let error):
print(error)
}
}
}
extension CodeModel: codeViewControllerOutput {
var displayable: DisplayableCode {
DisplayableCode(user: textCode)
}
in codeViewController class i am trying to call displayable
private func fillFields() {
let d = model.displayable
codeLabl.text = d.someTextcode
}
Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
