Skip to content

Instantly share code, notes, and snippets.

import UIKit
class ViewController: UIViewController {
// error: 'UISearchController' is only available on iOS 8.0 or newer
var searchController: UISearchController?
// error: Stored properties cannot be marked potentially unavailable with 'introduced='
@available(iOS 8.0, *)
var conditionallyAvailableSearchController: UISearchController?

Keybase proof

I hereby claim:

  • I am klundberg on github.
  • I am kevlario (https://keybase.io/kevlario) on keybase.
  • I have a public key ASAXKidIohQbWt66-UXKy-Ek8vejycrMu6F4xoG3oojvTQo

To claim this, I am signing this object:

let regex = try NSRegularExpression(pattern: mypattern, options: [])
let str = "some string to match"
if let result = regex.firstMatchInString(str, options: [], range: NSMakeRange(0, str.characters.count)) {
print((str as NSString).substringWithRange((result?.rangeAtIndex(1))!))
}
protocol BaseSection {
var cellIdentifier: String { get }
func numberOfRows() -> Int
func registerIdentifier(tableView: UITableView)
func configureCell(cell: UITableViewCell, indexPath: NSIndexPath)
}
class Section<T, Cell: UITableViewCell>: BaseSection {
var rows: [T] = []
var cellIdentifier = ""
struct TableViewSection<T, Cell: UITableViewCell> {
var cellIdentifier: String = ""
var items: [T] = []
var configureCell: (cell: Cell, item: T, indexPath: NSIndexPath) -> Void
}
class TableViewDataSource: NSObject, UITableViewDataSource {
var sections: [TableViewSection<?, ?>] = [] // I want arbitrary T/Cell types here, what do?
// ...