2015-09-01 57 views
0

我有一個alertController其中button。以下是我創建的button更改按鈕名稱

var myButton : UIAlertAction! 

// Later... 
self.myButton = UIAlertAction(title: "myButton", style: .Default, handler: {action -> Void in 
    self.myButton.title = "✔︎\(myButton)" 
}) 

後按鈕獲取的選擇,我想在標題前加上一個「✔︎」。 (你可以在上面的代碼中的最後一行看到的。)當我嘗試這樣做,我得到以下錯誤:

Cannot assign to the result of this expression

我能做些什麼來解決這個問題?如果myButtons標題是read-only,那麼是否有有效的解決方法?

回答

0

錯誤不是關於「✔︎」。這是因爲myButton。這意味着什麼都沒有分配UIAlertActionString。這就是你如何得到錯誤。