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 | |
typealias ParseResult = (output: Any, rest: Substring)? | |
func stringParser(input: Substring) -> ParseResult { | |
if input[input.startIndex] != "\"" { | |
return nil | |
} | |
var isEscape = true | |
let index = input.index() { |
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 | |
typealias ParseResult = (output: Any, rest: Substring)? | |
func stringParser(input: Substring) -> ParseResult { | |
if input[input.startIndex] != "\"" { | |
return nil | |
} | |
var isEscape = true | |
func inspectChar(char: Character) -> Bool { |
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 viewDidLoad() { | |
super.viewDidLoad() | |
// Do any additional setup after loading the view, typically from a nib. | |
view.backgroundColor = UIColor.lightGrayColor() | |
var hLayout = HorizontalFitLayout(height: 150) | |
hLayout.backgroundColor = UIColor.cyanColor() | |
view.addSubview(hLayout) |
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 viewDidLoad() { | |
super.viewDidLoad() | |
// Do any additional setup after loading the view, typically from a nib. | |
view.backgroundColor = UIColor.lightGrayColor() | |
var vLayout = VerticalFitLayout(width: view.frame.width) | |
vLayout.backgroundColor = UIColor.cyanColor() | |
view.addSubview(vLayout) |
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 VerticalFitLayout: VerticalLayout { | |
override init(width: CGFloat) { | |
super.init(width: width) | |
} | |
required init(coder aDecoder: NSCoder) { |
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 viewDidLoad() { | |
super.viewDidLoad() | |
// Do any additional setup after loading the view, typically from a nib. | |
view.backgroundColor = UIColor.lightGrayColor() | |
var hLayout = HorizontalLayout(height: 200) | |
hLayout.backgroundColor = UIColor.cyanColor() | |
view.addSubview(hLayout) |
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 HorizontalLayout: UIView { | |
var xOffsets: [CGFloat] = [] | |
init(height: CGFloat) { | |
super.init(frame: CGRectMake(0, 0, 0, height)) | |
} | |
required init(coder aDecoder: NSCoder) { |
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 VerticalScreenLayout: VerticalLayout { | |
init() { | |
super.init(width: UIScreen.mainScreen().bounds.width) | |
} | |
required init(coder aDecoder: NSCoder) { | |
fatalError("init(coder:) has not been implemented") |
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 viewDidLoad() { | |
super.viewDidLoad() | |
// Do any additional setup after loading the view, typically from a nib. | |
view.backgroundColor = UIColor.lightGrayColor() | |
var vLayout = VerticalLayout(width: view.frame.width) | |
vLayout.backgroundColor = UIColor.cyanColor() | |
view.addSubview(vLayout) |
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 VerticalLayout: UIView { | |
var yOffsets: [CGFloat] = [] | |
init(width: CGFloat) { | |
super.init(frame: CGRectMake(0, 0, width, 0)) | |
} | |
required init(coder aDecoder: NSCoder) { |
NewerOlder