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
//: Playground - noun: a place where people can play | |
import UIKit | |
import Foundation | |
// Merge overlapping times | |
// https://www.interviewcake.com/question/swift/merging-ranges?course=fc1§ion=array-and-string-manipulation | |
/** Your company built an in-house calendar tool called HiCal. You want to add a feature to see the times in a day when everyone is available. | |
*/ |
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 ContainerVC: BaseViewController { | |
override func loadView() { | |
view = ContainerView() | |
} | |
func addButton() { | |
// add the button | |
} | |
} |
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
Creating a concurrent queue | |
let concurrentQueue = DispatchQueue(label: "queuename", attributes: .concurrent) | |
concurrentQueue.sync { | |
} | |
Create a serial queue | |
let serialQueue = DispatchQueue(label: "queuename") | |
serialQueue.sync { |
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 setUpPriceTextField() { | |
priceTextField.delegate = self | |
priceTextField.addTarget(self, action: #selector(textFieldDidChange), forControlEvents: .EditingChanged) | |
} | |
// MARK: UITextFieldDelegate | |
func textFieldDidBeginEditing(textField: UITextField) { |
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 Number: String, ForwardIndexType { | |
case One | |
case Two | |
case Three | |
case Four | |
case EndIndex | |
func successor() -> Number | |
{ | |
switch self { |
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 someView = tester().waitForViewWithAccessibilityLabel("Notify Customer") | |
guard let disabledButton = someView as? UIButton else { | |
XCTFail("This view should return a button") | |
return | |
} | |
XCTAssertFalse(disabledButton.enabled) |
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
_ |
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
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/> |
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 nsRangeOfString(string: String) -> NSRange? { | |
guard let range = self.rangeOfString(string) else { return nil } | |
let startIndex = self.startIndex.distanceTo(range.startIndex) | |
return NSRange(location: startIndex, length: range.count) | |
} |
NewerOlder