deleting NSColorwell in Swift 3

35 views Asked by At

In my application, I create many instances of NSColorwell, and as I create each new instance, I assign it to an array of NSColorwells. By assigning the instances to an array, I maintain a reference to each of them so that I am able to manipulate the position and color of the NSColorwells. So far, so good. But when I no longer need the NSColorwells, I cannot delete them. What I really want to do is free up the memory that they have been using. I tried the removeAll() method for the array, but that merely cleared the array. No real surprise.

Is there a way to reclaim the memory?

1

There are 1 answers

0
Bob7430 On

I used removeFromSuperview(), which appears to free up the memory.

    while (index < CW.count) {
        CW[index].removeFromSuperview()
        index += 1
    }
    CW.removeAll()