ios - arc4random always returns same initial value on app start -
i developing application iphone that, in viewdidload, calls arc4random random number. problem each time application starts, gets same number arc4random. ought point out see behaviour when test app on iphone device , start application device touchscreen. if run app on device xcode, see different random numbers.
any or advice appreciated. thanks.
arc4random not need seeding , should not returning same results each time call it.
from comments, seems me code not being executed each time app comes foreground. remember when press home button app not terminated default. enter background, , resume when tap icon again.
if code inside viewdidload, called once means variable not updated , contain same value each time inspect it. when run xcode app terminated each time , expected behaviour.
you should put code in viewwillappear: or viewdidappear: called whenever view appears on screen, rather once when view loads.
Comments
Post a Comment