How to use autopoolrelease in swift

1.2k Views Asked by At

The use of autoreleasepool{} in swift is as follows.

autoreleasepool {
    // all usage here
}

But I do not know how to use it in public.

Example

class ViewController: UIViewController {
    autoreleasepool {
        var results: Results<Item>!
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        .....  
    }
}

If this is public, an error occurs. Does autoreleasepool{} need to be in func only?

0

There are 0 best solutions below