Skip to content

Instantly share code, notes, and snippets.

enum Shape {
case Rectangle(width: Int, height: Int)
case Circle(radius: Int)
}
func listMessages(completion: (messages: [Message]?, error: NSError?) -> Void) {
// Get the list of messages
// If success, call completion(messages: messages, error: nil)
// If error, call completion(messages: nil, error: error)
}
struct Message {
let text: String
let status: Status
}
struct Message {
let text: String
let status: Status
init?(dictionary: NSDictionary) {
guard
let text = dictionary["text"] as? String,
let statusString = dictionary["status"] as? String,
let status = Status(rawValue: statusString)
else { return nil }
enum Status: String {
case Draft = "draft"
case Sent = "sent"
case Failed = "failed"
}
enum Side: String {
case Top
case Left
case Bottom
case Right
}
enum Side: Int {
case Top
case Left
case Bottom
case Right
}
enum Side {
case Top
case Left
case Bottom
case Right
}
guard
let htmlPath = NSBundle.mainBundle().pathForResource("LICENSES", ofType: "html"),
let html = try? String(contentsOfFile: htmlPath, encoding: NSUTF8StringEncoding)
else {
fatalError("LICENSES.html not found.")
}
let webView = WKWebView(frame: CGRectZero, configuration: WKWebViewConfiguration())
webView.loadHTMLString(html, baseURL: nil)
#!/usr/bin/env xcrun swift -F Carthage/Build/Mac
import Foundation
import Markingbird
protocol Streamable {
var title: String { get }
var body: String { get }
}