In Swift, how can I use setValueForKey to set the textAlignment property of an object?
问题 Let's say we define an object like this: let object: AnyObject = { var result = UILabel(frame: CGRect(x: 0, y: 0, width: 150, height: 50)) result.text = "First Text" result.backgroundColor = UIColor.blueColor() return result }() For this example, I explicitly created a UILabel , but in my actual project I don't know what type of object is created, so I'm just treating the result as AnyObject for this example. The object is just a standard UILabel with text of "First Text" on a blue background