Skip to content

Instantly share code, notes, and snippets.

View jannejava's full-sized avatar

Jan Östlund jannejava

View GitHub Profile
@jorgenisaksson
jorgenisaksson / StringExtensions.swift
Last active April 3, 2017 08:45
Uppercase the first character of a Swift string
import Foundation
extension String {
func firstCharacterUpperCase() -> String {
if let firstCharacter = characters.first, characters.count > 0 {
return replacingCharacters(in: startIndex ..< index(after: startIndex), with: String(firstCharacter).uppercased())
}
return self
}
@jorgenisaksson
jorgenisaksson / ConformsToProtol.swift
Last active March 24, 2017 13:26
Check if a class conforms to a protocol instead of using respondsToSelector like in obj-c
import UIKit
// the protocol
protocol LayerManagerDelegate: class {
func doSomething()
}
// the class
class LayerManager {