Porting from Hung's android to iOS