in my app I've got a delay ,after 30 seconds its shows an alert but if the player collides with an object i'd like to deactivate the delay... any idea?
@ipodtouchacker IBAction is a subclass of void and void returns nothing. IBAction is the exact same thing as viod but interface builder looks at them and parses them differently.
@snipermaniac365 okay so the ibaction makes something happen to an object/outlet. and a void is just automatic actions? the thing im trying to do is have the screen change to yellow after 4 seconds when a song starts and black after another 4 or 5 seconds. i have the button make the song start and i made the background color change to yellow by doing a sleep(4), but i can't do it again for black color
@ipodtouchacker Don't use sleep(). Make 2 NSTimers that are called when the button is pressed and set the delay to however many seconds you want it to take for the void that contains the background changing code to be called. [NSTimer scheduledTimerWithTimeInterval:(seconds) target:self selector:@selector(anyFunction) userInfo:nil repeats:NO];
@snipermaniac365 ok i completely failed at what you told me to do. do i make an ibaction to have the NSTimers do what they do? im confused. the void is mostly the confusing part for me. i don't know where to put it in the code. i would write -(void) [NSTimer scheduledTimerWithTimeInterval :(4) target:self selector:@selector(myView.backgroundColor = [UIColor yellowColor] userInfo:nil repeats:NO];
@ipodtouchacker A void is a function much like an IBAction. You need to make a void like
- (void)functionName {
//code
}
As for the NSTimer, put myView.backgroundColor = [UIColor yellowColor] inside of a void and put the timer when you want to start the delay (viewDidLoad?). After the timer runs out it will call the function inside of the @selector(). So if you named the void functionName, you would put functionName inside of the @selector parenthesis.
@snipermaniac365 i finally got it!!!! after hours and thinking it makes perfect sense now! thank you so much for your help and the link above!!!! i made 2 voids. one called yellowChange and another called blackChange. Then i used the delay code instead of a NSTimer and made it refer to the yellowChange and another Delay code for blackChange. i put the delay code inside the action of making a song start. so when the song starts, it did the first delay and then the 2nd delay code worked too.THANKS
The most annoying thing is when you are trying to pause a video by clicking the video (which is what most people do) but instead of pausing the video, it redirects you to your channel forcing me to go back to the video and try to figure out where I was in the video before.
in my app I've got a delay ,after 30 seconds its shows an alert but if the player collides with an object i'd like to deactivate the delay... any idea?
sidorueckwaerts 7 months ago
great tutorial. im a beginner but when do you use voids and ibactions. i understand iboutlets and actions. but what's a void
ipodtouchacker 8 months ago
@ipodtouchacker IBAction is a subclass of void and void returns nothing. IBAction is the exact same thing as viod but interface builder looks at them and parses them differently.
snipermaniac365 8 months ago
@snipermaniac365 okay so the ibaction makes something happen to an object/outlet. and a void is just automatic actions? the thing im trying to do is have the screen change to yellow after 4 seconds when a song starts and black after another 4 or 5 seconds. i have the button make the song start and i made the background color change to yellow by doing a sleep(4), but i can't do it again for black color
ipodtouchacker 8 months ago
@ipodtouchacker Don't use sleep(). Make 2 NSTimers that are called when the button is pressed and set the delay to however many seconds you want it to take for the void that contains the background changing code to be called. [NSTimer scheduledTimerWithTimeInterval:(seconds) target:self selector:@selector(anyFunction) userInfo:nil repeats:NO];
snipermaniac365 8 months ago
@snipermaniac365 ok i completely failed at what you told me to do. do i make an ibaction to have the NSTimers do what they do? im confused. the void is mostly the confusing part for me. i don't know where to put it in the code. i would write -(void) [NSTimer scheduledTimerWithTimeInterval :(4) target:self selector:@selector(myView.backgroundColor = [UIColor yellowColor] userInfo:nil repeats:NO];
but how would it know when to do that?
ipodtouchacker 8 months ago
@ipodtouchacker A void is a function much like an IBAction. You need to make a void like
- (void)functionName {
//code
}
As for the NSTimer, put myView.backgroundColor = [UIColor yellowColor] inside of a void and put the timer when you want to start the delay (viewDidLoad?). After the timer runs out it will call the function inside of the @selector(). So if you named the void functionName, you would put functionName inside of the @selector parenthesis.
snipermaniac365 8 months ago
Comment removed
snipermaniac365 8 months ago
Comment removed
snipermaniac365 8 months ago
@ipodtouchacker bit.ly / jlU3Dr
snipermaniac365 8 months ago
@snipermaniac365 i finally got it!!!! after hours and thinking it makes perfect sense now! thank you so much for your help and the link above!!!! i made 2 voids. one called yellowChange and another called blackChange. Then i used the delay code instead of a NSTimer and made it refer to the yellowChange and another Delay code for blackChange. i put the delay code inside the action of making a song start. so when the song starts, it did the first delay and then the 2nd delay code worked too.THANKS
ipodtouchacker 8 months ago
The most annoying thing is when you are trying to pause a video by clicking the video (which is what most people do) but instead of pausing the video, it redirects you to your channel forcing me to go back to the video and try to figure out where I was in the video before.
MGuniverse 1 year ago 7
@MGuniverse You can turn off annotations.
XcodeDev 1 year ago 3
keep them coming!
brandflakeapps 1 year ago 4
cool :D
CaasiApp 1 year ago