Dopo aver rivisitato un codice che sembrava funzionare con Xcode6 beta 5, ho notato che sto ottenendo un "Impossibile convertire il tipo di espressione" [AnyObject]? " digitare "Errore 'NSArray' per questa linea:Impossibile convertire il tipo dell'espressione '[AnyObject]?' per digitare 'NSArray'
let textFields:NSArray = loginAlert.textFields as NSArray
Ecco la sezione di codice che sembra essere il problema:
override func viewDidAppear(animated: Bool) {
if PFUser.currentUser() == nil{
var loginAlert:UIAlertController = UIAlertController(title: "Sign Up/Login", message: "Please sign up or login", preferredStyle: UIAlertControllerStyle.Alert)
loginAlert.addTextFieldWithConfigurationHandler({
textfield in
textfield.placeholder = "Your username"
})
loginAlert.addTextFieldWithConfigurationHandler({
textfield in
textfield.placeholder = "Your password"
textfield.secureTextEntry = true
})
loginAlert.addAction(UIAlertAction(title: "Login", style: UIAlertActionStyle.Default, handler: {
alertAction in
let textFields:NSArray = loginAlert.textFields as NSArray
let usernameTextfield:UITextField = textFields.objectAtIndex(0) as UITextField
let passwordTextfield:UITextField = textFields.objectAtIndex(1) as UITextField
}))
}
Tutte le idee che il problema è?
Hai provato: 'loginAlert.textFields come ANYOBJECT! come NSArray' –