All I need to do is to create a CGRect
that encompasses a UIBezierPath
and I have an array of CGPoint
.
To create this CGRect
all I need to do is to enumerate the array of CGPoint
and find the minimum and maximum X and Y coordinates.
Then I remembered that the old and good NSArray
had this function called valueForKeyPath
that could be used in conjunction with something like valueForKeyPath:@max.x
or valueForKeyPath:@min.x
that would do the magic to find the minimum and maximum values of x and y.
I am new to Swift. This is the first time I am using Swift to create serious code.
Is there any magic in Swift arrays that can be used to do that, instead of creating complex enumerations and loops?