приложение ниже аварийно завершает работу, когда исходный код выполняется в: u.VerificaPermesso (...) , приложение проверяет на сервере покоя n узла вызовов.Код правильный, но сбои вы можете объяснить мне причину?Вызовы осуществляются на сервер rest node.js, который отвечает значением true или false и, в зависимости от того, отображается это значение или нет.
Swift Code:
import UIKit
class TabBarViewController: UITabBarController {
var u: User = User()
/* Genero L'UITabBarController creando le ViewController ed inserendole in un array! */
override func viewDidLoad() {
super.viewDidLoad()
var tabFrame = self.tabBar.frame
tabFrame.size.height = 60
self.tabBar.frame = tabFrame
hideKeyboardWhenTappedAround()
let MarcaTempoView = MarcaTempoViewController()
MarcaTempoView.tabBarItem = UITabBarItem(title: "Marca Tempo", image: UIImage(named: "clock.png")?.scaleImage(toSize: CGSize(width: 10, height: 10)), tag: 0)
let CantieriView = CantieriViewController()
CantieriView.tabBarItem = UITabBarItem(title: "Cantieri", image: UIImage(named: "home.png")?.scaleImage(toSize: CGSize(width: 10, height: 10)), tag: 1)
let ArticoliView = RicercaArticoliViewController()
ArticoliView.tabBarItem = UITabBarItem(title: "Articoli", image: UIImage(named: "articoli.png")?.scaleImage(toSize: CGSize(width: 10, height: 10)), tag: 2)
let UserView = UserViewController()
UserView.tabBarItem = UITabBarItem(title: "Utente", image: UIImage(named: "user.png")?.scaleImage(toSize: CGSize(width: 10, height: 10)), tag: 3)
let ClienteView = ClienteViewController()
ClienteView.tabBarItem = UITabBarItem(title: "Clienti", image: UIImage(named: "risorse_umane.png")?.scaleImage(toSize: CGSize(width: 10, height: 10)), tag: 4)
var viewControllerList = [MarcaTempoView, CantieriView, ArticoliView, ClienteView,UserView]
DispatchQueue.main.async {
//Controllo permesso accesso cantieri
let u = User()
//Controllo permesso accesso marcatempo
u.VerificaPermesso(TipologiaPermesso: "marcatempo", completion: { result in
DispatchQueue.main.async {
if(result == "false") {
viewControllerList.removeAll(where:{ $0 is MarcaTempoViewController })
self.viewControllers = viewControllerList
}
}
});
u.VerificaPermesso(TipologiaPermesso: "cantieri", completion: { result in
DispatchQueue.main.async {
if(result == "false") {
viewControllerList.removeAll(where:{ $0 is CantieriViewController })
self.viewControllers = viewControllerList
}
}
});
//Controllo permesso accesso Articoli
u.VerificaPermesso(TipologiaPermesso: "articoli", completion: { result in
DispatchQueue.main.async {
if(result == "false") {
viewControllerList.removeAll(where:{ $0 is RicercaArticoliViewController })
self.viewControllers = viewControllerList
}
}
});
//Controllo permesso accesso Clienti
u.VerificaPermesso(TipologiaPermesso: "clienti", completion: { result in
DispatchQueue.main.async {
if(result == "false") {
viewControllerList.removeAll(where:{ $0 is ClienteViewController })
self.viewControllers = viewControllerList
}
}
});
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
}