How to set the Timer in iphone - iphone

I just want to set the timer for the recorded voice. So, that it comes like an alarm after that time.(just like notifications).
Is that possible..
Any help will be greatly appreciated...
Thanks in Advance

Try reading NSTimer Class in developer documentation or you can refer this link

You might want to look at local notifications and NSTimer. Note that NSTimer doesn't work when the app is in the background.
Here is an example with NSTimer:
- (void)bar {
[NSTimer scheduledTimerWithTimeInterval:200.0f
target:self
selector:#selector(foo:)
userInfo:nil
repeats:YES];
}
- (void)foo:(NSTimer *)timer {
// Show alert or play recorded sound…
}
I'm afraid you can't play the recorded sound with local notifications, only when the app is in the foreground.

Related

multitasking in ios 4 later for notifications

i want to run one of my services in the background even my app is in foreground or background states,if i get any data from that service i want to show that one as a notification to the user. how can i proceed .
as my reserach gives me an idea to follow multi taking in iphone .
or shall i use any timer so that the method calls for particular time interval for every time
NSTimer *timer = [NSTimer timerWithTimeInterval:1 target:self selector:#selector(notification) userInfo:nil repeats:YES];
[timer fire];
-(void)notification
{
//shall i write all of my services here
}
or shall i create any new threads like
[self performSelectorInBackground:#selector(notification) withObject:Nil];
in AppDelegate file .
or shall i need to follow any other thing plz guide me thank you.
Generally, you should consider using push notifications sent by the server to show notifications to the user when something changes. This is preferable to running in the background since it is better for system performance & battery life.

Can I have set the time for Launch image(app Start up)..? I mean,for 5 seconds

I have added launch image in my application in info.plist. So,may I know is it possible to set the time for launching application for 5 seconds.Thanks
You can definitely do that, but you shouldn't. The user will be staring at an useless splash screen just for nothing.
In your app delegate's didFinishLaunching method, do:
sleep(5);
In your App delegate class, in the didFinishLaunchingWithOptions method.
[NSThread sleepForTimeInterval:5.0];
This will make your app waiting for 5 sec.
Yes. You can set time for launch image. Below is code. It may help you.
[NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:#selector(onLaunchExpire) userInfo:nil repeats:NO];
Use this and let me know for more details..

MPMoviePlayerController notification question

Good Evening Fellas!
Is it possible for me to get a notification from an MPMoviePlayerController while it is playing a video. I mean, if i am able to get it every second, millisecond etc.
I have an indicator for the video current playback time that i want it updated continuously.
Thank you in advance.
The simplest way is going to be to set up a repeating timer yourself, and use that to update your display. e.g.:
[NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:#selector(updateTime:) userInfo:nil repeats:YES];

How to make a function wait 30 seconds before it starts?

sorry still a newbie in the programming. Basically I have an Uibutton, when that button is pressed it would switch to another view, when it switches to that view, a function which calls a telephone number and sends an SMS text message out starts. What I'm trying to do it make that function wait 30seconds before it starts.
Any idea how to do this please?
just use:
-performSelector:withObject:afterDelay:
YOu can use NSTimer for that.
NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:30.0 target:self selector:#selector(myTimerMethod:) userInfo:nil repeats:NO];

Please confirm: NSTimer is to repeatedly make an event occur at intervals

I'm trying to make an iOS app. As part of the app, I want a UIScrollView to scroll every X seconds. I believe that I need to use NSTimer. Is this correct?
Yes. You can use NSTimer for this:
float interval = 2.5f; //whatever interval you want
NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:interval target:someTarget selector:#selector(someSelector:) userInfo:nil repeats:YES];
Yes. You can use NSTimer to perform either a delayed event or a periodic event. There is a good post on using NSTimer here.
Yes.
NSTimer* theTimer = [NSTimer scheduledTimerWithTimeInterval:X
target:someController
selector:#selector(scrollThatView)
userInfo:nil
repeats:YES];
You don’t need to use an NSTimer—there are other ways to do it—but yes, an NSTimer will allow you to do so.