stoy tratando de obtener datos de usuario registrados en el perfil en swift 4
Estoy tratando de obtener un ID de inicio de sesión en particular en el perfil, pero no puedo obtenerlo. He visto muchos enlaces, pero no funciona para mí. A continuación se muestra mi función que he utilizado para obtener datos
Funció
func getCompanyFunc() {
let empURL = URL(string: "http://172.16.1.22/Get-Company-API/get-companies/")
URLSession.shared.dataTask(with: empURL!) { (data, response, error) in
do {
if error == nil {
self.getCompanyArray = try JSONDecoder().decode([CompanyDataProfile].self, from: data!)
for mainArr in self.getCompanyArray {
DispatchQueue.main.async {
let companyDefaultValue = UserDefaults.standard
if let userID = companyDefaultValue.string(forKey: "user_type_id") {
self.getComData = self.getCompanyArray.filter { $0.company_id == userID }
print("Company ID Profile=\(userID)")
self.companyName_lbl.text = mainArr.company_name
}
}
}
print("****Employee Data****\(self.getCompanyArray)")
}
}
catch {
print("Error in get JSON Data Employee\(error)")
}
}.resume()
}