Skip to content
This repository has been archived by the owner on Jan 17, 2024. It is now read-only.

Replace NSTimer with CADisplayLink and segue with dismissViewController #7

Merged

Conversation

bgayman
Copy link
Contributor

@bgayman bgayman commented Apr 26, 2016

It is not recommended to use NSTimer for animations and other UI updates. Use CADisplayLink instead. Also to reverse view controller presentation you should use an unwind segue or dismissViewController not a forward segue as it will instantiate a new view controller and repeated initialization of view controllers can lead to memory warning/termination or suboptimal performance.

@MoralCode MoralCode merged commit c7e362c into MoralCode:Converting-Time Apr 26, 2016
@MoralCode
Copy link
Owner

@bgayman is there any way to set the CADisplayLink to run at specific intervals?

@bgayman
Copy link
Contributor Author

bgayman commented Apr 26, 2016

Why would that be useful?

@MoralCode
Copy link
Owner

MoralCode commented Apr 26, 2016

@bgayman i have a feature in the code (stressTestMode) that rapidly cycles through every time to test the clock and time display/calculation functionality...

@bgayman
Copy link
Contributor Author

bgayman commented Apr 26, 2016

No, you can't set the interval. The interval is set by the system. You can use a timestamp to ignore calls, otherwise it will be called before each rendering pass, this ensure that you are getting optimal performance and that you will not drop frames. If you are just doing it for testing purposes it would be better to just log to console or if you feel it is necessary you can write a different function that advances time more rapidly rather than just reading it from NSDate.

I don't know what you mean by "do you have any ideas as to how i could layout the UI? (see latest commit….)" You want the minute hand to sweep rather than tick?

@MoralCode
Copy link
Owner

okay.

i was referring to the conversion screen when i was talking about the UI, although a sweeping second hand may be a great optional feature!

do you have any idea how i can allow users to more rapidly increment/decrement the minutes and seconds on the conversion screen?

@MoralCode
Copy link
Owner

@bgayman i just looked at the timer using the code in this pull request, and have concluded that the occasional time skip (issue #3) is not due to the inaccuracy of the NSTimer (now CADisplayLink) but to the fact that there are 864 milliseconds in one metric second, as opposed to 1000 in "normal time"...

If you do find a fix for this, however, I would love to know what it is...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants