Skip to content

Instantly share code, notes, and snippets.

@NicholasTD07
Created January 12, 2016 10:58
Show Gist options
  • Save NicholasTD07/144552defd6429d1d981 to your computer and use it in GitHub Desktop.
Save NicholasTD07/144552defd6429d1d981 to your computer and use it in GitHub Desktop.
Things go wrong in Swift 2.1
/// # Things go wrong in Swift 2.1
/// ## A protocol overriding/giving default implementation to its parent's methods
/// If you have a class conform to this protocol and try compile, you will get segmentation fault 11.
protocol SingleSectionTableViewDataSource: UITableViewDataSource {
typealias ItemType
var items: [ItemType] { get set }
}
extension SingleSectionTableViewDataSource {
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return items.count
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment