Objective-C round 100ms NSTimeInterval to nearest 100
NSTimeInterval that returns a double, for example, that fires every 100ms with scheduledTimerWithTimeInterval:0.1 as the NSTimer.
double posNumber = 1157.483277;
// If number is positive, 1200.
int ms = 100 * round(posNumber / 100);
// Can also use floor() on positive, and ceil() on negative numbers
Written by Matthew Teece
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ios
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#