JKになりたい

何か書きたいことを書きます。主にWeb方面の技術系記事が多いかも。

2016-09-15から1日間の記事一覧

よく使うExtension(2) UITableView カスタムセルの登録

extension UITableView { func registerCell<T: UITableViewCell>(type: T.Type) { let className = type.className let nib = UINib(nibName: className, bundle: nil) registerNib(nib, forCellReuseIdentifier: className) } func registerCells<T: UITableViewCell>(types: [T.Type]) { types.for</t:></t:>…

よく使うExtension(1) Array Safe

インデックスの範囲外にアクセスした場合に例外を起こさずにnilを返すExtension extension CollectionType { subscript (safe index: Index) -> Generator.Element? { return indices.contains(index) ? self[index] : nil } } let numbers = [1,2,3,4] numb…