func viewDidLoad guard let userData UserManager shared let profile use

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
func viewDidLoad() {
guard let userData = UserManager.shared, let profile = userData.profile else {
view?.showLoading()
UserManager.loadUserDataFromServer(complition: { [weak self] (user) in
self?.view?.hideLoading()
if let profile = user.profile {
let pictureURL = URL(string: profile.picture)
self?.view?.showAvatar(pictureUrl: pictureURL)
self?.view?.showName(name: profile.fullName)
} else {
// TO-DO Add user full name placeholder
// TO-DO Add image placeholder
}
}) { [weak self] (error) in
self?.view?.hideLoading()
self?.view?.displayError(error)
}
return
}
let pictureURL = URL(string: profile.picture)
view?.showName(name: profile.fullName)
view?.showAvatar(pictureUrl: pictureURL)
}