Should be easily portable to Swift.
Activity