If you just need to print a CGRect
or CGSize
, you could use:
println(rect)
or
println(size)
You left a '...' at the end of your function so I assume there are more types that you need to print. To do that you need to make those types conform to the Printable
protocol (unless they already do). Here's an example of how -
class Car {
var mileage = 0
}
extension Car : Printable {
var description: String {
return "A car that has travelled \(mileage) miles."
}
}
The you can use:
let myCar = Car()
println(myCar)
Also, you may want to change the format of the way a type is currently printed. For example, if you wanted println(aRect)
in the same format as returned by NSStringFromCGRect
you could use the extension:
extension CGRect : Printable {
public var description: String {
return "{\(origin.x), \(origin.y)}, {\(size.width), \(size.height)}"
}
}