Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Hot Sauce79

macrumors newbie
Original poster
Jul 1, 2008
22
0
Hi again everyone,

Now im trying to figure out how to run a function every time a certain amount of time has elapsed. I have tried using the NSTimer function but it does not seem to run my code.

The code i want it to run changes the Array's that I had talked about in a previous thread and i want it to run once every second or something like that.

When i run the code with NSTimer it does not redraw the screen that i want it to redraw. It just sits on the screen unchanged and stares at me.

Any suggestions/help would be greatly appreciated!
 

liptonlover

macrumors 6502a
Mar 13, 2008
989
0
I just made a thread because I was trying to get NSTimer to work... it's still in the first page of mac programming, it's just called NSTimer. I posted my original code, people pointed things out, I responded, and finally I posted the working code. Learn from it :) I can now say I know how to use NSTimer!
 

Krevnik

macrumors 601
Sep 8, 2003
4,101
1,312
Well, two quick things to try here is:

A) Set a breakpoint in your code that is supposed to be called when the timer triggers. Make sure the breakpoint gets hit.

B) Look at the code to make sure the UI is being told to update. Just changing data won't cause a refresh unless someone is actually watching it and gets notified of it.
 

Hot Sauce79

macrumors newbie
Original poster
Jul 1, 2008
22
0
Ok i figured out what i had wrong with my timer so now it works. It turns out I was accidently invalidating it before I even used it >.< But my problem seems to run a little bit deeper than that.

My screen still isnt updating and i checked using breakpoints and it is hitting the code that should be updating my screen.

It is going through all of the code right and I am still adding breakpoints in different areas to make sure it is hitting them correctly

Once again any and all help is appreciated!
 

Hot Sauce79

macrumors newbie
Original poster
Jul 1, 2008
22
0
Here is the code that I am trying to rerun that isnt running the way it should. I was thinking that maybe it is my problem.

Code:
spacey = 60;
spacex = 20;
	
for(NSUInteger x=0;x<20;x++) {
	for(NSUInteger y=0;y<10;y++) {			
		[[[myArray objectAtIndex:x] objectAtIndex:y] drawAtPoint:(CGPointMake(spacey,spacex))];
		spacey += 20;	
	}
	spacey = 60;
	spacex += 20;
}
spacex = 20;


According to the breakpoints the code is running fine, however the application is not changing its appearance at all.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.