This file contains 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 isValidIPv4(_ ip: String) -> Bool { | |
return ip | |
.characters.split(separator: ".").map { String($0) } | |
.flatMap { Int($0) } | |
.filter { (0...255).contains($0) } | |
.count == 4 | |
} |
This file contains 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
//: Playground - noun: a place where people can play | |
import UIKit | |
class AView: UIView { | |
override init(frame: CGRect) { | |
super.init(frame: frame) | |
customInitialisation() | |
} |
This file contains 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
// | |
// MyAppAccount | |
// | |
struct MyAppAccount { | |
let latch = Latch(service: (NSBundle.mainBundle().bundleIdentifier ?? "com.example.MyApp")) | |
var username: String? { |
This file contains 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
// | |
// AlertView.swift | |
// | |
import UIKit | |
// holding array so the AlertView objects don't go out of scope | |
internal var alerts = [AlertView]() |
This file contains 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
extension NSUUID { | |
var toString: String { | |
return self.UUIDString | |
} | |
} | |
let uuid = NSUUID().toString |
This file contains 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
Sep 16 05:13:57 i5s SpringBoard[48] <Warning>: Received memory warning. | |
Sep 16 05:13:57 i5s discoveryd[50] <Notice>: Basic DeviceInformation Memory Pressure Warning sent: pressure | |
Sep 16 05:13:57 i5s MobileMail[1305] <Warning>: Received memory warning. | |
Sep 16 05:13:57 i5s MobilePhone[1176] <Warning>: Received memory warning. | |
Sep 16 05:13:57 i5s MobileSMS[316] <Warning>: Received memory warning. | |
Sep 16 05:13:57 i5s InCallService[163] <Warning>: Received memory warning. | |
Sep 16 05:13:57 i5s syncdefaultsd[1848] <Notice>: (Warn ) received memory warning | |
... | |
Sep 16 05:14:20 i5s Kindle[1827] <Warning>: Received memory warning. | |
... |
This file contains 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 error: NSError? = nil | |
if self.managedObjectContext?.save(&error) == true { | |
return | |
} | |
NSLog("Unresolved error \(error), \(error!.userInfo)") |
This file contains 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 saveContext () { | |
return if self.managedObjectContext == nil | |
return if self.managedObjectContext?.hasChanges == false | |
var error: NSError? = nil | |
return if self.managedObjectContext?.save(&error) == true | |
NSLog("Unresolved error \(error), \(error!.userInfo)") | |
abort() | |
} |