How to detect device rotation event in iOS Swift 3:

Detecting device rotation is not a big secret but doing this in a clean way is important. I mean adding and removing the observers in correct time/place. Many developer are adding  observers without removing with exit. This leads memory leaks and performance issues.