我有一个功能:
static func VerifyDeviceId(deviceId: String, userName: String) -> DeviceVerifyResponse? {
var verifyResponseResult:DeviceVerifyResponse = DeviceVerifyResponse();
apiProvider.request(.VerifyDeviceId(deviceId: deviceId, username: userName)){
result in
if case .success(let response) = result{
do{
verifyResponseResult = try response.map(to: DeviceVerifyResponse.self, keyPath: "verifyDeviceLoginResult");
print(verifyResponseResult);
}
catch(let error){
print(error);
}
}
}
return verifyResponseResult;
}
然后我在其他视图控制器中调用它
func GetUserReturned() -> [Bool:User]{
self.user = VerifyViewModel().Login(userName: tbxInsideCode.text!, password: tbxPassword.text!)!;
if(user != nil){
return [true:user!];
}
else{
return [false:User()];
}
}
在我调用该函数后,它返回了一个空对象。但事情是在第二个视图加载后,它然后返回一个包含所有参数的对象。
可以请任何人解释我在哪里做错了吗?