-1

If I have this code below to tell the UIPicker if nothing is selected to set the feet to 1, How can I delay this action a few seconds?

// If feet values are zero.
if (([feetPicker selectedRowInComponent:0] == 0 & [feetPicker selectedRowInComponent:1] == 0)){
// Set to one foot.
[feetPicker selectRow:1
          inComponent:1
             animated:YES];


}
Jason
  • 650
  • 2
  • 10
  • 33
  • Why an NSTimer of course. :-) – Josiah Apr 05 '13 at 16:28
  • Can you provide an example based on the code above please? – Jason Apr 05 '13 at 17:17
  • Why do people ask other people to write their code for them? – matt Apr 05 '13 at 18:05
  • Because thats the point of this site, for other to help others that are not as advanced at programming, I'm not asking you to write it, im asking for an example, I tried NSTimer, and I can't get it to work. – Jason Apr 05 '13 at 18:10
  • What do you mean "can't get it to work"? NSTimer does work. People use it all the time. There is *lots* of working NSTimer on stack overflow and elsewhere; just google for it. Or show *your* code and then we can correct it. – matt Apr 05 '13 at 18:18
  • 1
    @Jason, I posted an answer. I hope that helps. – Josiah Apr 05 '13 at 19:15
  • @Jason, It should be noted though, that your conception of Stack Overflow is misleading. Stack Overflow is actually meant for professionals, so while we are fine helping, with such simple answers, we do expect people to be able to read some documentation on how to do this. Just letting you know. :) Good luck! – Josiah Apr 05 '13 at 19:18
  • 1
    Nothing wrong with this question. @matt, if I could downvote your comments I would - if he can 'just google for it' it renders stackoverflow a little redundant, don't you think? Maybe think before you post and stop making people feel bad for asking questions? – davbryn Apr 05 '13 at 19:23
  • Thank you to those that have helped. With all do respect, I understand for the more advanced programmers, a question such as this seems simple, and therefore, annoying. However, the answer is only easy if you know it. I'm sure there was a time when you didn't know this, and someone was there to help you. If not, then more power to you. I do this on the side, and not as my main profession. What I have learned so far I have learned on my own or by asking questions on this site that has proved very helpful most of the time. Thank you to all that's willing to pass the knowledge! – Jason Apr 05 '13 at 19:30
  • As a side note, I have ran into many people that have had knowledge of something others did not, and weren't willing to pass that knowledge along, sadly, for people like this, the knowledge they carry is useless if it can't be passed down! – Jason Apr 05 '13 at 19:41
  • @Jasonm I'm glad this helped you! I personally don't mind giving some code if you don't completely understand it, everyone has to learn. That's why usually I post a short answer as a comment as see if that helps enough, otherwise writing an answer is no problem. I simply pointed out the fact that many people may not be happy with your questions just as a heads up. Anyway, good luck in your future endeavors! – Josiah Apr 05 '13 at 19:49
  • I understand, I was just pointing out there are many people that are trying to learn that are not happy with their "answers". :) – Jason Apr 05 '13 at 19:50

1 Answers1

2
[NSTimer    scheduledTimerWithTimeInterval:2.0    target:self    selector:@selector(fireMethod)    userInfo:nil repeats:NO];

The above code can be placed whenever you want to start the timer.

-(void)fireMethod {
    // If feet values are zero.
if (([feetPicker selectedRowInComponent:0] == 0 & [feetPicker selectedRowInComponent:1] == 0)){
// Set to one foot.
[feetPicker selectRow:1
          inComponent:1
             animated:YES];


    }
}
Josiah
  • 4,663
  • 2
  • 31
  • 49
  • Thank you for your help!! And allowing me to see an example I can get to work, and "see" how it works!! it really is greatly appreciated!! – Jason Apr 05 '13 at 19:38