Skip to content

Instantly share code, notes, and snippets.

View mejiagarcia's full-sized avatar
🏠
Working from home

Carlos Mejía mejiagarcia

🏠
Working from home
View GitHub Profile
@cprovatas
cprovatas / Data+PrettyPrint.swift
Created May 23, 2018 15:52
Pretty print JSON string from Data in Swift 4.1 (especially useful printing to Xcode console)
import Foundation
extension Data {
var prettyPrintedJSONString: NSString? { /// NSString gives us a nice sanitized debugDescription
guard let object = try? JSONSerialization.jsonObject(with: self, options: []),
let data = try? JSONSerialization.data(withJSONObject: object, options: [.prettyPrinted]),
let prettyPrintedString = NSString(data: data, encoding: String.Encoding.utf8.rawValue) else { return nil }
return prettyPrintedString
}
@bolivarbryan
bolivarbryan / BBLabel.swift
Last active May 10, 2018 19:44
UILabel component, ready to use
import UIKit
class BBLabel: UILabel {
enum FontSize: CGFloat {
case small = 12.0
case medium = 14.0
case large = 30.0
}