"math.random"only work on Simulator but doesn't work on iOS Device

when I install the apps into iOS Device, the random result is always same when the apps open in every first time.

Anyone can tell me what I forget to do? 

my sample Lua code as follow:


display.setStatusBar(display.TranslucentStatusBar)

display.setDefault(“background”,0,0,0)

local rect = display.newRect(400,400,200,200)

local number=0

num = display.newText(number,100,300,native.SystemFont,85)

function rect:tap(event)

   num.text = ("");

   number=math.random(1,9)

   num = display.newText(number,100,300,native.SystemFont,85)

end

rect:addEventListener(“tap”,rect)


You never seed the random number generator.

Add: 

math.randomseed( os.time() )

near the top of your code.  The device’s default to seeding with 0 all the time, so you get the same series of numbers.

Rob

You never seed the random number generator.

Add: 

math.randomseed( os.time() )

near the top of your code.  The device’s default to seeding with 0 all the time, so you get the same series of numbers.

Rob