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
| enum Food: String { | |
| case beef = "Beef" | |
| case chicken = "Chicken" | |
| case vegitarian = "Vegitarian" | |
| case kids = "Kids" | |
| } | |
| struct Person { | |
| let name: String | |
| let food: Food |
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 HTTP | |
| import Vapor | |
| extension Droplet { | |
| func index(of middlewareType: Middleware.Type) -> Int? { | |
| for (i, middleware) in self.middleware.enumerated() { | |
| if type(of: middleware) == middlewareType.self { | |
| return i | |
| } |
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 sketch = context.api() | |
| function moveForward(layer, amount) { | |
| for (var i = 0; i < amount; ++i) { | |
| layer.moveForward() | |
| } | |
| } | |
| function organizeLayers(prefix, layers) { | |
| var sortedLayers = []; |
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
| func romanNumerals(input: Int) -> String { | |
| var number = input | |
| let numerals = ["M", "M", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"] | |
| let values = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1] | |
| var numeralString = "" | |
| for (i, numeral) in numerals.enumerate() { | |
| while number >= values[i] { | |
| number -= values[i] | |
| numeralString += numeral |
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 dateFormatter = NSDateFormatter() | |
| dateFormatter.dateFormat = "MMMM d" | |
| private func daySuffix(date: NSDate) -> String { | |
| let calendar = NSCalendar.currentCalendar() | |
| let dayOfMonth = calendar.component(.Day, fromDate: date) | |
| switch dayOfMonth { | |
| case 1: fallthrough | |
| case 21: fallthrough | |
| case 31: return "st" |
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
| userNoteLabel.text = configData["user_note"] as? String |
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
| copyrightLabel.text = configData["copyright"] as! String |
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 mainBundle = NSBundle.mainBundle() | |
| let config = mainBundle.pathForResource(“Config”, ofType: “plist”)! | |
| let configData = NSDictionary(contentsOfFile: config)! |
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
| override func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { | |
| return self.messageData.count ?? 0 | |
| } |
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
| self.window?.tintColor = self.tintColor(configData) ?? UIColor.redColor() |