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 | |
| struct Distance { | |
| let value: Double | |
| } | |
| struct Time { | |
| let value: Double | |
| } |
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 <objc/runtime.h> | |
| @implementation UIViewController(Tracking) | |
| + (void)load { | |
| static dispatch_once_t onceToken; | |
| dispatch_once(&onceToken, ^{ | |
| [self swizzleOriginalSelector:@selector(performSegueWithIdentifier:sender:) | |
| swizzledSelector:@selector(xxx_performSegueWithIdentifier:sender:)]; |
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
| #!/bin/bash | |
| # Script to count lines of code (.swift and .h and .m) for XCode projects | |
| find . "(" -name "*.swift" -or -name "*.m" -or -name "*.h" ")" -print0 | xargs -0 wc -l | sort -n |
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 prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { | |
| segue.destinationViewController.title = customTitle() | |
| } |
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 DestinationViewController: UIViewController { | |
| var viewModel: ViewModel! | |
| @IBOutlet var label: UILabel! | |
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
| // viewModel should be set by prepareForSegue. It it's not, |
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
| // MARK: UITableViewDelegate | |
| func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { | |
| let cell = tableView.cellForRowAtIndexPath(indexPath) | |
| if shouldPerformSegue(cell) { | |
| self.performSegueWithIdentifier("CellDetailSegue", sender: cell) | |
| } | |
| } |
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 ViewController: UIViewController, UIPopoverPresentationControllerDelegate { | |
| @IBAction var sourceButton: UIButton! | |
| override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { | |
| if segue.identifier == "SlideshowPopoverSegue" { | |
| let contentViewController = segue.destinationViewController | |
| contentViewController.modalPresentationStyle = UIModalPresentationStyle.Popover | |
| if let popover = contentViewController.popoverPresentationController { |
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
| protocol TitlePresentable { | |
| var titleLabel: UILabel! { get set } | |
| func setTitle(title: String?) | |
| } | |
| extension TitlePresentable { | |
| func setTitle(title: String?) { | |
| titleLabel.text = title | |
| } | |
| } |
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
| protocol BytesCountPresentable { | |
| var bytesCountLabel: UILabel! { get set } | |
| func setBytesCount(bytesCount: Int64?) | |
| } | |
| extension BytesCountPresentable { | |
| func setBytesCount(bytesCount: Int64?) { | |
| bytesCountLabel.text = bytesCountString(bytesCount) | |
| } | |
| private func bytesCountString(bytesCount: Int64?) -> String { |
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 BytesCountTitleTableViewCell: UITableViewCell, TitlePresentable, BytesCountPresentable { | |
| @IBOutlet var titleLabel: UILabel! | |
| @IBOutlet var bytesCountLabel: UILabel! | |
| } |
OlderNewer