View rangesOfSubstrings.swift
extension String {
func ranges(of subString: String) -> [NSRange] {
var result: [NSRange] = []
var start = startIndex
while let range = range(of: subString, options: .literal, range: start..<endIndex) {
let startPos = self.distance(from: self.startIndex, to: range.lowerBound)
let endPos = self.distance(from: self.startIndex, to: range.upperBound)
result.append(NSMakeRange(startPos, (endPos - startPos)))
start = range.upperBound
}
View AHKActionSheet swift sample code
let actionSheet:AHKActionSheet = AHKActionSheet(title:"My title")
actionSheet.buttonHeight = 60
actionSheet.cancelButtonHeight = 80.0
actionSheet.addButtonWithTitle("the title", image: UIImage(named: "icon.png"), type: AHKActionSheetButtonType.Default, handler: { (AHKActionSheet) -> Void in
println("tapped on this button !")
})