Skip to content

Instantly share code, notes, and snippets.

View zigzagg16's full-sized avatar
🏠
Working from home

zig zag zigzagg16

🏠
Working from home
View GitHub Profile
@zigzagg16
zigzagg16 / rangesOfSubstrings.swift
Last active December 19, 2017 09:55
Swift String : rangesOf substrings
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
}
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 !")
})