This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Encode params to be web friendly and return a string. Reference ->http://stackoverflow.com/a/27724627/6091482 | |
extension String { | |
/// Percent escapes values to be added to a URL query as specified in RFC 3986 | |
/// | |
/// This percent-escapes all characters besides the alphanumeric character set and "-", ".", "_", and "~". | |
/// | |
/// http://www.ietf.org/rfc/rfc3986.txt | |
/// |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func applicationDidReceiveMemoryWarning(application: UIApplication) { | |
NSURLCache.sharedURLCache().removeAllCachedResponses() | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class VerticalLayout: UIView { | |
var yOffsets: [CGFloat] = [] | |
init(width: CGFloat) { | |
super.init(frame: CGRectMake(0, 0, width, 0)) | |
} | |
required init(coder aDecoder: NSCoder) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mutating func moveItem(fromIndex oldIndex: Index, toIndex newIndex: Index) { | |
insert(removeAtIndex(oldIndex), atIndex: newIndex) | |
} | |
var tags = [1,2,3,4,5,7782,25] | |
tags.moveItem(fromIndex: 2, toIndex: tags.count-1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mutating func shuffle() { | |
if count < 2 { return } | |
for i in 0..<(count - 1) { | |
let j = Int(arc4random_uniform(UInt32(count - i))) + i | |
swap(&self[i], &self[j]) | |
} | |
} | |
var tags = [1,7782,25] | |
tags.shuffle() |
NewerOlder