How to pass a "title" in a "UIAlertController" of type Int with swift?

1

Good afternoon, guys.

I'm calling an alert in my code where I need its "title" to be the return id of a JSON, my json object has id and status, the id is of type Int, and the status is of type String, I tried to convert the id to string, but at the time of loading it is different from the return of json, below is the part of my code that is loading the id and images of the simulator when executing the code:

func showActionSheetSenha(){
    var actions = [UIAlertAction]()

    for obj in containerSenha.arraySenhas{
        let status = obj.status
        let id = String(format: "%f", obj.id)

        actions.append(Alerta.createAction(id, style: .Default, handler: {(paramAction) in
            self.campoField.text = id
            self.senhaAtual = obj as Senha
        }))
    }

    Alerta.showAlert(nil, message: nil, preferredStyle: .ActionSheet, actions: actions, viewController: self) { () -> Void in
        self.view.endEditing(true)
    }
}

When I replace the id with the status to appear in the alert, it works, it shows the normal status. Thanks in advance for your help.

    
asked by anonymous 07.11.2015 / 21:29

1 answer

2

You've tried instead of:

let id = String(format: "%f", obj.id)

do:

let id = "\(obj.id)"

???

    
07.11.2015 / 23:35