Reputation: 167
I have a like button in an action sheet:
likeAction = UIAlertAction(title: "Like this post", style: UIAlertActionStyle.Default, handler: { (action) -> Void in
println("like pressed")
})
Once pressed I'd like to update the title to "Unlike this post"
Title is readonly and there isn't a SetTitle() function on UIAlertActions.
Ideas much appreciated.
Upvotes: 2
Views: 1662
Reputation: 1259
This works for me.
self.alertAction.setValue("New Title", forKeyPath: "title")
Hope this helps.
Upvotes: 8
Reputation: 167
This was answered by Lyndsey Scott in a comment on the original post.
Set a bool variable to indicate whether the post is "liked" then set the alert title conditionally.
Upvotes: -1