Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

momo arn00s

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