Skip to content

Commit

Permalink
Merge pull request #38 from nghialv/swift2.2
Browse files Browse the repository at this point in the history
swift 2.2
  • Loading branch information
nghialv committed Apr 7, 2016
2 parents 92a3b3b + 9c36141 commit 1968826
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 13 deletions.
8 changes: 4 additions & 4 deletions Hakuba/ArrayExt.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ extension Array {
func getSafeRange(range: Range<Int>) -> Range<Int>? {
let start = max(0, range.startIndex)
let end = min(count, range.endIndex)
return start <= end ? Range<Int>(start: start, end: end) : nil
return start <= end ? start..<end : nil
}

func get(index: Int) -> Element? {
return hasIndex(index) ? self[index] : nil
}

mutating func append(newArray: Array) -> Range<Int> {
let range = Range<Int>(start: count, end: count + newArray.count)
let range = count..<(count + newArray.count)
self += newArray
return range
}
Expand All @@ -46,7 +46,7 @@ extension Array {
let left = self[0..<start]
let right = self[start..<count]
self = left + newArray + right
return Range<Int>(start: start, end: end)
return start..<end
}

mutating func move(fromIndex from: Int, toIndex to: Int) -> Bool {
Expand All @@ -67,7 +67,7 @@ extension Array {
return nil
}
removeAtIndex(index)
return Range<Int>(start: index, end: index + 1)
return index..<(index + 1)
}

mutating func remove(range: Range<Int>) -> Range<Int>? {
Expand Down
2 changes: 1 addition & 1 deletion Hakuba/CellType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

public protocol CellType {
typealias CellModel
associatedtype CellModel

var cellmodel: CellModel? { get }
}
Expand Down
8 changes: 5 additions & 3 deletions Hakuba/Hakuba.swift
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ public extension Hakuba {

for j in 0..<sectionsCount {
if let k = sortedIndexes.get(i) where k == j {
i++
i += 1
} else {
remainSections.append(sections[j])
}
Expand Down Expand Up @@ -500,9 +500,11 @@ extension Hakuba: UITableViewDataSource {
// MARK - Private methods

private extension Hakuba {
func setupSections(sections: [Section], var fromIndex start: Int) {
func setupSections(sections: [Section], fromIndex start: Int) {
var start = start
sections.forEach {
$0.setup(start++, delegate: self)
$0.setup(start, delegate: self)
start += 1
}
}
}
2 changes: 1 addition & 1 deletion Hakuba/HeaderFooterViewType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

public protocol HeaderFooterViewType {
typealias ViewModel
associatedtype ViewModel

var viewmodel: ViewModel? { get }
}
Expand Down
11 changes: 7 additions & 4 deletions Hakuba/Section.swift
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public extension Section {

for j in 0..<count {
if let k = sortedIndexes.get(i) where k == j {
i++
i += 1
} else {
remainCellmodels.append(cellmodels[j])
}
Expand Down Expand Up @@ -231,14 +231,17 @@ extension Section {
// MARK - Private methods

private extension Section {
func setupCellmodels(cellmodels: [CellModel], var indexFrom start: Int) {
func setupCellmodels(cellmodels: [CellModel], indexFrom start: Int) {
guard let delegate = delegate as? CellModelDelegate else {
return
}

for cellmodel in cellmodels {
let indexPath = NSIndexPath(forRow: start++, inSection: index)
var start = start

cellmodels.forEach { cellmodel in
let indexPath = NSIndexPath(forRow: start, inSection: index)
cellmodel.setup(indexPath, delegate: delegate)
start += 1
}
}
}

0 comments on commit 1968826

Please sign in to comment.