@available(iOS 10.0, *)
import UserNotifications
NSUserNotification API Reference
UNNotificationSound API Reference
UNUserNotificationCenter API Reference
| @UIApplicationMain | |
| class AppDelegate: UIResponder, UIApplicationDelegate { | |
| var window: UIWindow? | |
| func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { | |
| // Override point for customization after application launch. | |
| let window = UIWindow(frame: UIScreen.main.bounds) | |
| self.window = window |
| extension Double { | |
| public static let kRectX = 30.0 | |
| public static let kRectY = 30.0 | |
| public static let kRectWidth = 30.0 | |
| public static let kRectHeight = 30.0 | |
| } | |
| public func makeRect() -> CGRect { | |
| return CGRect(x: .kRectX, y: .kRectY, width: .kRectWidth, height: .kRectHeight) | |
| } |
@available(iOS 10.0, *)
import UserNotifications
NSUserNotification API Reference
UNNotificationSound API Reference
UNUserNotificationCenter API Reference
| let _0_delay = 3.0 * Double(NSEC_PER_SEC) | |
| let _0_time = DispatchTime.now() + Double(Int64(_0_delay)) / Double(NSEC_PER_SEC) | |
| DispatchQueue.main.acyncAfter(deadline: _0_time, execute: { | |
| }) | |
| DispatchQueue.main.acyncAfter(deadline: DispatchTime.now() + Double(Int64(3.0 * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC), execute: { | |
| }) |
| import Foundation | |
| // 💡: 元の例では型が指定されてなかったけど、この場合多分enumかな | |
| enum Element { | |
| case Electric, Fire | |
| } | |
| /********** Abstract Pokemon **********/ |
| import Foundation | |
| import XCTest | |
| class Ref { | |
| var success = false | |
| } | |
| import Swift | |
| /*: | |
| A simple type-erased sequence | |
| */ | |
| let seq = AnySequence([1,2,3]) | |
| /*: | |
| ## Who Needs Types Like That? |
Functional programming gets a bad wrap about being too hard for mere mortals to comprehend. This is nonsense. The concepts are actually quite simple to grasp.
The jargon is the hardest part. A lot of that vocabulary comes from a specialized field of mathematical study called category theory (with a liberal sprinkling of type theory and abstract algebra). This sounds a lot scarier than it is. You can do this!
All examples using ES6 syntax. wrap (foo) => bar means:
function wrap (foo) {| /* | |
| 모나드는 특정한 타입을 감싸는 타입이며, | |
| raw한 값을 감싸는 함수와 | |
| raw한 값을 모나드 값으로 바꾸는 어떤 함수에 바인딩된다. | |
| 이를 바탕으로 모나드 프로토콜을 정의하면 다음과 같다. | |
| */ | |
| protocol Monad { |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.