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
import Foundation | |
extension String { | |
/// Returns true if a string is a valid palindrome. | |
var isPalindrome: Bool { | |
let scalars = utf16 | |
if scalars.count < 2 { return true } |
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 Optional { | |
func flatMapWith<T, U>(_ other: T?, _ transform: (Wrapped, T) -> U?) -> U? { | |
guard case .some(let `self`) = self else { | |
return nil | |
} | |
guard let element = other else { | |
return nil | |
} | |
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
import UIKit | |
import PlaygroundSupport | |
class FirstTable: UITableViewController, UIViewControllerTransitioningDelegate { | |
lazy var animator = TransitionAnimator() | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "reuseID") |
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
let pushTopicSubscriptionStates = ["Sports": true, "News": false] | |
// an array of topics that user is subscribed to | |
let subscribedUserTopics = pushTopicSubscriptionStates.filter { (_, subscribed) in subscribed } | |
.map { (topic, _) in topic | |
} |
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
/* RAC*/ | |
let userNameStrings = userNameTextfield | |
.rac_textSignal() | |
.toSignalProducer() | |
.map { text in text as! String } | |
let passwordStrings = passwordTextfield.rac_textSignal() | |
.toSignalProducer() | |
.map { password in password as! String } | |