Author: Chris Lattner
func createEventinTheCalendar(with title:String, forDate eventStartDate:Date, toDate eventEndDate:Date) { | |
store.requestAccess(to: .event) { (success, error) in | |
if error == nil { | |
let event = EKEvent.init(eventStore: self.store) | |
event.title = title | |
event.calendar = self.store.defaultCalendarForNewEvents // this will return deafult calendar from device calendars | |
event.startDate = eventStartDate | |
event.endDate = eventEndDate | |
- Proposal: SE-XXXX
- Authors: Chris Lattner, Joe Groff
Modern Cocoa development involves a lot of asynchronous programming using closures and completion handlers, but these APIs are hard to use. This gets particularly problematic when many asynchronous operations are used, error handling is required, or control flow between asynchronous calls gets complicated. This proposal describes a language extension to make this a lot more natural and less error prone.
This paper introduces a first class Coroutine model to Swift. Functions can opt into to being async, allowing the programmer to compose complex logic involving asynchronous operations, leaving the compiler in charge of producing the necessary closures and state machines to implement that logic.
import Cocoa | |
extension String { | |
// https://stackoverflow.com/a/36258684/2227743 | |
var containsEmoji: Bool { | |
for scalar in self.unicodeScalars { | |
switch scalar.value { | |
case 0x1F600...0x1F64F, // Emoticons | |
0x1F300...0x1F5FF, // Misc Symbols and Pictographs |
extension Sequence { | |
func map<T>(_ keyPath: KeyPath<Element, T>) -> [T] { | |
return self.map { | |
$0[keyPath: keyPath] | |
} | |
} | |
func flatMap<T>(_ keyPath: KeyPath<Element, T?>) -> [T] { | |
return self.flatMap { | |
$0[keyPath: keyPath] |
declare var __DEV__: boolean; | |
declare module 'react-native' { | |
declare type Color = string | number; | |
declare type Transform = | |
{ perspective: number } | | |
{ scale: number } | | |
{ scaleX: number } | |
// | |
// Obfuscator.swift | |
// | |
// Created by Dejan Atanasov on 2017-05-31. | |
// | |
import Foundation | |
class Obfuscator: AnyObject { | |
import Foundation | |
struct Country { | |
let name: String | |
let capital: String | |
var visited: Bool | |
} | |
extension Country: Equatable { | |
static func == (lhs: Country, rhs: Country) -> Bool { |
####Rets Rabbit http://www.retsrabbit.com
Rets Rabbit removes the nightmare of importing thousands of real estate listings and photos from RETS or ListHub and gives you an easy to use import and Web API server so you can focus on building your listing search powered website or app.
// | |
// SKMultilineLabel.swift | |
// | |
// Created by Craig on 10/04/2015. | |
// Copyright (c) 2015 Interactive Coconut. | |
// MIT License, http://www.opensource.org/licenses/mit-license.php | |
// | |
/* USE: | |
(most component parameters have defaults) | |
let multiLabel = SKMultilineLabel(text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", labelWidth: 250, pos: CGPoint(x: size.width / 2, y: size.height / 2)) |