The array will actually respond to the valueForKeyPath function - you just need to pass the array to AnyObject so that the compiler does not complain. As below:
var max = (numbers as AnyObject).valueForKeyPath("@max.self") as Double
or even to combine objects:
(labels as AnyObject).valueForKeyPath("@unionOfObjects.text")
If labels above is a set of labels, then an array of all lines of the text property of each label will be returned above.
It is also equivalent to the following:
(labels as AnyObject).valueForKey("text")
... just like in Objective-C :)
Sam
source share