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
extension String | |
{ | |
public static func localize(_ key: String, comment: String) -> String { | |
return NSLocalizedString(key, comment: comment) | |
} | |
func format(parameters: CVarArg...) -> String { | |
return String(format: self, arguments: parameters) | |
} | |
} |
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
import UIKit | |
public struct PersonItem | |
{ | |
var title: String | |
init(title: String) { | |
self.title = title | |
} | |
} |
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
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 | |
} |
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
import UIKit | |
// the protocol | |
protocol LayerManagerDelegate: class { | |
func doSomething() | |
} | |
// the class | |
class LayerManager { | |
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
// Adapted from Cocoa Drawing Guide's "Create a CGPathRef fram an NSBezierPath Object" | |
func CGPathFromNSBezierPath(nsPath: NSBezierPath) -> CGPath! { | |
if nsPath.elementCount == 0 { | |
return nil | |
} | |
let path = CGPathCreateMutable() | |
var didClosePath = false | |