Skip to content

Instantly share code, notes, and snippets.

View Marcocanc's full-sized avatar
🚀

Marco Cancellieri Marcocanc

🚀
View GitHub Profile
@Marcocanc
Marcocanc / UIFont+FontWeight.swift
Created March 8, 2017 16:17
really hoping this will work out of the box in future versions
public extension UIFont {
public class func systemFont(ofSize fontSize: CGFloat, weight: UIFontWeight) -> UIFont {
return .systemFont(ofSize: fontSize, weight: weight.floatValue)
}
public class func monospacedDigitSystemFont(ofSize fontSize: CGFloat, weight: UIFontWeight) -> UIFont {
return .monospacedDigitSystemFont(ofSize: fontSize, weight: weight.floatValue)
}
}
@Marcocanc
Marcocanc / JSON+Decimal.swift
Last active April 20, 2017 09:24
JSON+Decimal
import Foundation
import SwiftyJSON
extension JSON {
public var decimal: Decimal? {
get {
switch self.type {
case .string:
return Decimal(string: self.object as! String)
case .number:
@Marcocanc
Marcocanc / UITableView+DeselectAny.swift
Created February 20, 2017 13:41
deselect any UITableViewRow that may be selected
extension UITableView {
//deselect any row that may be selected
public func deselectAnyRow(animated: Bool = true) {
if let indexPath = self.indexPathForSelectedRow {
self.deselectRow(at: indexPath, animated: animated)
}
}
}
@Marcocanc
Marcocanc / ExternalIntent.swift
Last active January 27, 2017 13:37
External Intent Enum
enum ExternalIntent {
case content(id: String)
case timeline
case example
init?(launchOptions: [UIApplicationLaunchOptionsKey: Any]?) {
guard let launchOptions = launchOptions else { return nil }
if let url = launchOptions[.url] as? URL {
self.init(url: url)
} else if let shortcutItem = launchOptions[.shortcutItem] as? UIApplicationShortcutItem {