This file contains 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
@interface BaseViewModel : NSObject | |
- (void)baseMethod; | |
@end | |
@implementation BaseViewModel | |
- (void)baseMethod {} | |
@end | |
// --------------------------------------------------------------------------------------------------------------------- |
This file contains 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 <Foundation/Foundation.h> | |
// Assume -fobjc-arc ... 假設有 ARC | |
// | |
// 存成 `main.m` 然後在 Terminal 跑 `clang -framework Foundation -fobjc-arc -o main main.m && ./main && rm main` | |
// 然後在 `./main` 就會動囉 | |
// | |
NSArray *ggFunction1(NSError *__autoreleasing *error) { | |
@autoreleasepool { |
This file contains 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 <Foundation/Foundation.h> | |
// Assume -fno-objc-arc ... 假設沒 ARC | |
@interface MyObject: NSObject | |
@end | |
@implementation MyObject |
This file contains 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
struct String { | |
mutating func append(_ c: Character) | |
mutating func append(_ other: String) | |
} |
This file contains 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
viewController.dismiss(true) // bad | |
viewController.dismiss(animated: true) | |
viewController.dismissAnimated(true) // worse |
This file contains 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
let friends: [Friend] = ... | |
friends.remove(ted) // remove(_:) | |
friends.remove(at: positionOfTed) // remove(at:) |
This file contains 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
#include <iostream> | |
typedef struct { | |
int quotient; | |
int remainder; | |
} DivideResult; | |
DivideResult divide(int dividend, int divisor) { | |
return (DivideResult){.quotient=dividend/divisor, .remainder=dividend%divisor}; | |
} |
This file contains 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
func move(from origin: String, to destination: String) -> String { | |
return "Move from \(origin) to \(destination)." | |
} | |
let string = move(from: "Tokyo", to: "Taipei") | |
print(string) |
This file contains 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
func move(from: String, to: String) -> String { | |
return "Move from \(from) to \(to)." | |
} | |
let string = move(from: "Tokyo", to: "Taipei") | |
print(string) |
This file contains 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
public class Example { | |
static String move(String origin, String destination) { | |
return String.format("Move from %s to %s.", origin, destination); | |
} | |
public static void main(String[] args) { | |
String string = Example.move("Tokyo", "Taipei"); | |
System.out.println(string); | |
} | |
} |