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 Foundation | |
struct Random { | |
static func randomNumberUpTo(upTo: Int) -> Int { | |
return Int(arc4random_uniform(UInt32(upTo))) | |
} | |
static func randomNumberInRange(range: Range<Int>) -> Int { | |
let distance = range.endIndex - range.startIndex | |
let random = randomNumberUpTo(distance) |
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
struct NoteSpeller { | |
static let wordURL = "https://raw.githubusercontent.com/dwyl/english-words/master/words.txt" | |
static let delimiter: Character = "\n" | |
static let notesNames: [Character] = ["a", "b", "c", "d", "e", "f", "g"] | |
static func getWords(includeH: Bool = false) -> [String] { | |
var notes = notesNames | |
if includeH { | |
notes.append("h") |
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 sendEmail(email: Email, completion: SendEmailCompletionBlock) -> Request { | |
let fields: JSONDict = [ | |
"first_name" : email.firstName, | |
"last_name" : email.lastName, | |
"email_address" : email.emailAddress, | |
"ip_address" : email.ipAddress, | |
"vendor_id" : email.vendorID, | |
"event_date_epoch" : email.eventDateEpoch, | |
"message" : email.message, | |
"phone" : email.phoneNumber |
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
// objc.io Issue #9 | |
// February, 2014 | |
// String Parsing by Chris Eidhof | |
// | |
// Example 3 | |
// Swift version by Rob Hudson | |
import UIKit | |
let FormatError = 100 |
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
// objc.io Issue #9 | |
// February, 2014 | |
// String Parsing by Chris Eidhof | |
// | |
// Example 2 | |
// Swift version by Rob Hudson | |
import UIKit | |
let FormatError = 100 |
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
// objc.io Issue #9 | |
// February, 2014 | |
// String Parsing by Chris Eidhof | |
// | |
// Swift version by Rob Hudson | |
import UIKit | |
// NSTextCheckingResult using NSRange, rather than Range<String.Index>, so we need an NSString, rather than a String | |
let string: NSString = "backgroundColor = #ff0000" |
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
// Light-weight Swift smart quote implementation | |
// By Rob Hudson | |
// 5/11/2015 | |
import UIKit | |
let text = "\"Would you tell me, please, which way I ought to go from here?\" " + | |
"That depends a good deal on where you want to get to,\" said the Cat. " + | |
"\"I don’t much care where-\" said Alice. " + | |
"Then it doesn’t matter which way you go,\" said the Cat. " + |
NewerOlder