Quote:
it doesnt work for me
This is probably the most useless problem report we get - and we get it a lot. It tells us nothing about what is happening, or when it happens.
So tell us what it is doing that you didn't expect, or not doing that you did.
Tell us what you did to get it to happen.
Tell us any error messages.
And in this case, start with the debugger:
Apple Debugging Tools[
^] and look at what happens when you do set the index "back to zero".
Testing and debugging your code are a big part of development: it's not unusual to spend 10% of your time writing code, and 90% making it work correctly! So while you are still dealing with tiny little apps like this one, that's the perfect time to get familiar with the tools you will need for bigger, more complex tasks. Debugging is a skill - and like all skills it has to be used in order to develop. Just going "it doesn't work" and expecting others to fix it for you isn't going to help you at all in the long run, even if it gets you out of a hole in the short term!
Give it a try, and see how much you can find out!