Questions tagged [nstimeinterval]

an Objective-C Foundation Data Type that specifies a time interval

NSTimeInterval is an Foundation Data Type that specifies a time interval. NSTimeInterval values are in seconds.

Resources

Related Tags

364 questions
6
votes
3 answers

How to get NSTimeInterval value from last boot

I need to get NSTimeInterval value from last device boot. I found CACurrentMediaTime() which suits this task, but in my app I am not using Core Animation and I don't think that this is the best way to include this framework just to get this…
voromax
  • 3,369
  • 2
  • 30
  • 53
6
votes
2 answers

How do I find the time interval remaining from NSTimer

I have set a NSTimer.scheduledTimerWithTimeInterval method which has an interval every 20 minutes. I want to be able to find out how much time is left when the the app goes into background mode. How do I find out how much time is left from the…
Henry Brown
  • 2,219
  • 8
  • 31
  • 48
5
votes
2 answers

[NSCFString timeIntervalSinceReferenceDate]: unrecognized selector sent to instance

I would like to compare difference between two dates, but with the code below I got the error "[NSCFString timeIntervalSinceReferenceDate]: unrecognized selector sent to instance." What's wrong with the code? NSDate *dateAdded=[eventDictionary…
Nimit Pattanasri
  • 1,602
  • 1
  • 26
  • 37
5
votes
2 answers

Adding and Subtracting times in Swift

I've written some of this in pseudo code because I don't know the syntax for it. I'd like to have the timeLeftLabel.text reflect how many hours, minutes, and seconds are left until the 6 hours are up. My biggest problem is that I don't know how to…
adman
  • 408
  • 1
  • 4
  • 21
5
votes
1 answer

How to correctly format a NSTimeInterval as a time period, respecting i18n?

Given an NSTimeInterval representing a period of time, how do I create a human-readable string that expresses that time period in a way that respects i18N? For example, if the NSTimeInterval is equal to 10823.23435 seconds, then some reasonable ways…
Chris
  • 941
  • 9
  • 18
5
votes
1 answer

How do you get the "current system time"?

The documentation of SKScene -update is as follows: What exactly is "the current system time," and how can I get it other than via SKScene -update? I've tried CFAbsoluteTimeGetCurrent(), but apparently that Returns the current system absolute…
Michael Dorst
  • 8,210
  • 11
  • 44
  • 71
5
votes
2 answers

iOS error "Initializing 'NSTimeInterval *' (aka 'double *')

I'm trying to get the time interval between two NSDates, namely previousActivity.stopTimeand previousActivity.startTime. I'm getting an error with this code: NSTimeInterval *previousActivityDuration = [previousActivity.stopTime…
rattletrap99
  • 1,469
  • 2
  • 17
  • 36
5
votes
1 answer

dateWithTimeIntervalSince1970 not returning correct date

I have the following method below that is meant to retrieve and convert a unixTimeStamp from an API call to a NSDate object that I can easily manipulate and use. For some reason, this returns wrong values. An example would be when the unixTimeStamp…
TheCodingArt
  • 3,436
  • 4
  • 30
  • 53
5
votes
3 answers

How to store NSTimeInterval values into a NSMutableArray?

I have a requirement where i have a Video that is played using MPMediaPlayerController. Along with the video i have two buttons where i need to capture the current playback time when the button are clicked and store all the relevant clicks…
Pradeep Reddy Kypa
  • 3,992
  • 7
  • 57
  • 75
4
votes
1 answer

Using a NSTimer for HH:MM:SS?

How can I change this code so it has HH:MM:SS (hours, minutes, seconds)? Do I need to add code in .h or .m so I known which one? At the moment it goes up like 1, 2, 3, 4 etc. Just to let you known I'm bait of a amateur would you copy and past so I…
Paul Mastes
  • 71
  • 2
  • 7
4
votes
3 answers

Convert NSString into NSTimeInterval

I tried to make a countdown with the NSTimeInterval. But I want to be able to change the interval without releasing an update each time. So I tried to import the Timeinterval from my website. I've stored the numbers for the NSTimeInterval in a…
AmiiQo
  • 353
  • 1
  • 7
  • 17
4
votes
1 answer

conversion from NSTimeInterval to days

I have a date1 and the current Date when the view did load. Now I want to display how many days have passed since the day. let timeInterval = date1.timeIntervalSince(date2) Now I want to convert the timeInterval in days. Anyone could help?
4
votes
3 answers

Measuring time Interval Since Now

anyone know or can provide some example code relating to "timeIntervalSinceNow" method... I need something like... time2(when app eneters foreground) - time1(when app enters background) = time3(the difference in times)... this is so i can use this…
myles
  • 75
  • 1
  • 1
  • 8
4
votes
2 answers

Getting current time when device was shutting down

I am new to programming. As one of my app need updates if the device is shutting down (switched off), hence I need the current time when the device is getting switched off. and I know that, we can get the system boot time (switched on time) with…
Abirami Bala
  • 760
  • 1
  • 10
  • 25
4
votes
1 answer

Random Time in between two times (a range) iOS SDK

I am trying to create a random time for a notification to occur that is between two times, a range... I would like iOS to create a time between say 09:30AM and 11:30AM. I was thinking of using the random number generator for the hours and another…
OscarTheGrouch
  • 2,374
  • 4
  • 28
  • 39
1 2
3
24 25