CocoaPods trunk is moving to be read-only. Read more on the blog, there are 14 months to go.
| TestsTested | ✓ |
| LangLanguage | Obj-CObjective C |
| License | BSD |
| ReleasedLast Release | Sep 2015 |
Maintained by Kyle Fuller.
It's easy to forget that CGFloat may actually be a double despite it's
name. On 64-bit systems, where CGFLOAT_IS_DOUBLE is set to 1 it will actually
be a double.
This may become cumbersome when you are developing an application where you want a single code base which builds for both 32-bit and 64-bit such as when developing against the 32-bit simulator and deploying arm64.
CGFloatType is a simple library which provides methods on NSNumber to help
deal with this. Along with providing various math and rounding functions
which accepts CGFloat.
This helps you change:
#if CGFLOAT_IS_DOUBLE
CGFloat points = ceil(pointsPerMinute * durationMinutes);
#else
CGFloat points = ceilf(pointsPerMinute * durationMinutes);
#endifInto something like:
CGFloat points = ceilCGFloat(pointsPerMinute * durationMinutes);#import <CGFloatType/CGFloatType.h>
@implementation Example
- (void)example {
NSNumber *number = [NSNumber numberWithCGFloat:CGRectGetHeight(self.view.frame)];
NSLog(@"NSNumber with value: %@", number);
CGFloat value = [number CGFloatValue];
CGFloat floorValue = floorCGFloat(value);
CGFloat ceilValue = ceilCGFloat(value);
NSLog(@"%@ (floor = %@, ceil = %@)", @(value), @(floorValue), @(ceilValue));
}
@endpod 'CGFloatType'CGFloatType is released under the BSD license. See LICENSE.