我必须处理这些字符串,这些字符串位于用户登录失败时弹出的警报内。
这就是现在的样子
FaultCode : Faltou informar o usuário!
FaultCode : Campo obrigatório
这应该是这样的:
FaultCode : Faltou informar o usuário!
FaultCode : Campo obrigatório
这是我正在使用的UIAlertAction:
let loginAlert = UIAlertController(title:faultActor, message: faultString, preferredStyle: .alert)
let acaoDefault = UIAlertAction(title: "OK", style: .destructive, handler: nil)
loginAlert.addAction(acaoDefault)
present(loginAlert, animated: true, completion: nil)
这是我编写的用于处理响应的函数: manageFaultMessage是一个处理来自我的Web服务的故障消息的函数。
func manageFaultMessage(faultMessage: XMLIndexer, requestName: String) throws {
//Fault SOAP Message
let faultXML = faultMessage["SOAP-ENV:Envelope"]["SOAP-ENV:Body"]["SOAP-ENV:Fault"]
if faultXML.children.count > 0 {
guard let faultCode: String = faultXML["faultcode"].element?.text else {
throw XMLParseError.UnknownField
}
guard let faultActor: String = faultXML["faultactor"].element?.text else {
throw XMLParseError.UnknownField
}
guard let faultString: String = faultXML["faultstring"].element?.text else {
throw XMLParseError.UnknownField
}
guard let detail: String = faultXML["detail"].element?.text else {
throw XMLParseError.UnknownField
}
self.delegate.didFaultRequest(faultCode: faultCode, faultActor: faultActor, faultString: faultString, detail: detail, requestName: nomeServico)
} else {
throw XMLParseError.EmptyXML
}
}
现在我应该在哪里添加编码以及如何添加?