Skip to content

Instantly share code, notes, and snippets.

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)
enum Side {
case Top
case Left
case Bottom
case Right
}
enum Side: Int {
case Top
case Left
case Bottom
case Right
}
enum Side: String {
case Top
case Left
case Bottom
case Right
}
enum Status: String {
case Draft = "draft"
case Sent = "sent"
case Failed = "failed"
}
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 }
struct Message {
let text: String
let status: Status
}
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)
}
enum Shape {
case Rectangle(width: Int, height: Int)
case Circle(radius: Int)
}
enum Result {
case Success(messages: [Message])
case Error(error: NSError)
}