This file contains hidden or 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 UIKit | |
import RealmSwift | |
class ViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// Do any additional setup after loading the view, typically from a nib. | |
let realm = try! Realm() |
This file contains hidden or 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 Vapor | |
/// Register your application's routes here. | |
public func routes(_ router: Router) throws { | |
// Saving models | |
router.post("api", "acronyms") { req -> Future<Acronym> in | |
return try req.content.decode(Acronym.self) | |
.flatMap(to: Acronym.self) { acronym in | |
return acronym.save(on: req) |
This file contains hidden or 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 Vapor | |
/// Register your application's routes here. | |
public func routes(_ router: Router) throws { | |
/* // Example of configuring a controller | |
let todoController = TodoController() | |
router.get("todos", use: todoController.index) | |
router.post("todos", use: todoController.create) | |
router.delete("todos", Todo.parameter, use: todoController.delete) */ |
This file contains hidden or 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
private var previousController: UINavigationController? = nil; | |
func tabBarController(_ tabBarController: UITabBarController, didSelect viewController: UIViewController) { | |
guard let navigationController = tabBarController.viewControllers?[tabBarController.selectedIndex] as? UINavigationController else { | |
return | |
} | |
let canScrollToTop = navigationController == previousController |
This file contains hidden or 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
// Step 1: class ViewController: ..... URLSessionDelegate, URLSessionTaskDelegate | |
// Step 2: Usage | |
if let url = NSURL(string: "https://example.com") { | |
let session = URLSession( | |
configuration: URLSessionConfiguration.ephemeral, | |
delegate: NSURLSessionPinningDelegate(), | |
delegateQueue: nil) |
This file contains hidden or 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
var smtpSession = MCOSMTPSession() | |
smtpSession.hostname = "" | |
smtpSession.username = "" | |
smtpSession.password = "" | |
smtpSession.timeout = 5 | |
smtpSession.port = UInt32(port!)! | |
smtpSession.authType = MCOAuthType.saslPlain | |
smtpSession.connectionType = MCOConnectionType.startTLS | |
smtpSession.connectionLogger = {(connectionID, type, data) in | |
if data != nil { |
This file contains hidden or 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
class BottomBorderTF: UITextField { | |
var bottomBorder = UIView() | |
override func awakeFromNib() { | |
//MARK: Setup Bottom-Border | |
self.translatesAutoresizingMaskIntoConstraints = false | |
bottomBorder = UIView.init(frame: CGRect(x: 0, y: 0, width: 0, height: 0)) | |
bottomBorder.backgroundColor = UIColor.orange | |
bottomBorder.translatesAutoresizingMaskIntoConstraints = false |
This file contains hidden or 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
// | |
// UILabelDeviceClass.swift | |
// | |
// Created by MyCandy on 01/01/19. | |
// Copyright © 2019 Silver Seahog. All rights reserved. | |
// | |
import Foundation | |
import UIKit |
This file contains hidden or 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 prefs:NSUserDefaults = NSUserDefaults.standardUserDefaults() //make this global | |
// Mark: This is how you save. | |
prefs.setObject("\(someVariable)", forKey: "PORT") | |
prefs.synchronize() | |
//Mark: This is how you retrieve saved content. | |
let retrieve = prefs.valueForKey("PORT") as? String | |
print(retrieve) |
NewerOlder