Swift Swift - 4 years ago 252
Swift Question

How to delete CGRect in Swift?

I'm developing for macOS. I wanna have an ability to delete newly created CGRect in compiled app. How to do that?

let rectangle = CGRectMake(0, 0, 30, 30)

Answer Source

CGRect cannot be deleted since it is just a type of a size, struct and cannot be displayed straight on your UI. (it will be deleted automatically when it goes out of scope in your code.) A CGRect could be assigned as the frame of a UIView(in iOS)/NSView that can be added to the screen and be deleted later using a reference. If you want to delete a frame of a view, just assign the frame a CGRect.zero. That wont delete the frame but will make the frame to stick to the top left corner of the screen and have a height and width equal to zero.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download