| function | debug | release | release |
|---|---|---|---|
| Optimization Level | -Onone |
-O |
-Ounchecked |
assert() |
YES | NO | NO |
assertionFailure() |
YES | NO | NO** |
precondition() |
YES | YES | NO |
preconditionFailure() |
YES | YES | YES** |
fatalError()* |
YES | YES | YES |
| Value | Meaning |
| function | debug | release | release |
|---|---|---|---|
| Optimization Level | -Onone |
-O |
-Ounchecked |
assert() |
YES | NO | NO |
assertionFailure() |
YES | NO | NO** |
precondition() |
YES | YES | NO |
preconditionFailure() |
YES | YES | YES** |
fatalError()* |
YES | YES | YES |
| Value | Meaning |
| defaults read <domain> | grep -o --regexp="\"NSWindow Frame [^\"]*\"" | xargs -L1 defaults delete <domain> |
| // In Objective-C, a relatively long method call could be easily wrapped on multiple lines: | |
| [attributedString addAttribute:NSParagraphStyleAttributeName | |
| value:paragraphStyle | |
| range:NSMakeRange(0, attributedString.length)]; | |
| // But how do you do that in Swift? | |
| attributedString.addAttribute(NSParagraphStyleAttributeName, value: paragraphStyle, range: NSRange(location: 0, length: attributedString.length)) |
| var total : Int | |
| let myString = "foo" | |
| // When originally looking at Swift's switch statements, you may think this is how you get fall through behaviour: | |
| total = 0 | |
| switch myString { | |
| case "foo": | |
| total += 4 | |
| case "foo", "bar": | |
| total += 2 |
| [[UIBarButtonItem appearance] setBackButtonBackgroundImage:[[UIImage imageNamed:@"IMG"] resizableImageWithCapInsets:UIEdgeInsetsMake(4, 4, 4, 4)] | |
| forState:UIControlStateNormal | |
| barMetrics:UIBarMetricsDefault]; | |
| [[UIBarButtonItem appearance] setTitleTextAttributes:@{NSFontAttributeName: [UIFont fontWithName:@"Courier" size:16], | |
| NSForegroundColorAttributeName: [UIColor redColor]} | |
| forState:UIControlStateNormal]; |
| CGFloat red = 0.08f; | |
| CGFloat green = 0.49f; | |
| CGFloat blue = 0.98f; | |
| CGFloat hue = 0.59f; | |
| CGFloat saturation = 0.92f; | |
| CGFloat brightness = 0.98f; | |
| CGFloat alpha = 1.0f; |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <unistd.h> | |
| #define main main() { printf("Loading program..."); unsigned int i=1; while (1) { sleep(i++); printf("."); fflush(stdout); } } int nope | |
| int main() | |
| { | |
| printf("Hello, World!\n"); | |
| return EXIT_SUCCESS; |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #define main main(){ return EXIT_SUCCESS; } int nope | |
| int main() | |
| { | |
| printf("Hello, World!\n"); | |
| return EXIT_SUCCESS; | |
| } |
| #include <stdio.h> | |
| #define MAIN int main(int argc, const char * argv[]) { printf("Hello, World!\n"); return 0; } | |
| MAIN |
| #define UIViewAutoresizingFlexibleDimensions (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight) | |
| #define UIViewAutoresizingFlexibleMargins (UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin) |