Skip to content

Instantly share code, notes, and snippets.

@CocoaDebug
CocoaDebug / gist:40ff4aac920b3febed2ce9d2868e68c6
Created March 24, 2018 10:29 — forked from shadcn/gist:de147c42d7b3063ef7bc
Convert a Hex string to UIColor in Swift
// Creates a UIColor from a Hex string.
func colorWithHexString (hex:String) -> UIColor {
var cString:String = hex.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet()).uppercaseString
if (cString.hasPrefix("#")) {
cString = cString.substringFromIndex(1)
}
if (countElements(cString) != 6) {
return UIColor.grayColor()
@CocoaDebug
CocoaDebug / BinaryDataScanner.h
Created February 25, 2018 07:26 — forked from davepeck/BinaryDataScanner.h
Two simple Objective-C classes that make it crazy easy to read data from sequential binary files.
//
// BinaryDataScanner.m
//
// Copyright 2009 Dave Peck <davepeck [at] davepeck [dot] org>. All rights reserved.
// http://davepeck.org/
//
// This class makes it quite a bit easier to read sequential binary files in Objective-C.
//
// This code is released under the BSD license. If you use it in your product, please
// let me know and, if possible, please put me in your credits.
@CocoaDebug
CocoaDebug / ArrayDeepCopy.swift
Created January 8, 2018 15:42 — forked from sohayb/ArrayDeepCopy.swift
Array deep copy in Swift
//Protocal that copyable class should conform
protocol Copying {
init(original: Self)
}
//Concrete class extension
extension Copying {
func copy() -> Self {
return Self.init(original: self)
}