mafioso mafioso - 1 year ago 173
Swift Question

How to refresh photo gallery in swift?

How can I refresh the photo gallery in swift? If I take a picture I have to close the app and then restart it to see it. I want to refresh the gallery automatically. What's the best way to solve this problem?

Answer Source

Add this to your viewDidLoad method:
NSTimer.scheduledTimerWithTimeInterval(1.0, target: self, selector: #selector(ViewController.refreshView), userInfo: nil, repeats: true) and implement in the refreshView what you want to do.

Better method: use an observer pattern!

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