Last active
August 29, 2015 14:12
-
-
Save puls/cef53c8acc64e0c1e89c to your computer and use it in GitHub Desktop.
Swift CGFloat
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #import <UIKit/UIKit.h> | |
| [NSString stringWithFormat:@"%.0f", 1.23]; // @"1" | |
| [NSString stringWithFormat:@"%.0f", (double)1.23]; // @"1" | |
| [NSString stringWithFormat:@"%.0f", (float)1.23]; // @"1" | |
| [NSString stringWithFormat:@"%.0f", (CGFloat)1.23]; // @"1" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| String(format: "%.0f", 1.23) // "1" | |
| String(format: "%.0f", Double(1.23)) // Same thing as above, "1" | |
| String(format: "%.0f", Float(1.23)) // "1" | |
| String(format: "%.0f", CGFloat(1.23)) // "0" |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
TIL:
CGFloatin Swift is not atypealiasbut astruct: