iOS: fix a potential crash