Skip to content

Instantly share code, notes, and snippets.

@pawan-preet
pawan-preet / AutolayoutHelper.swift
Last active August 5, 2019 11:19
Helper Class to ease Constraints when adding Programatically.
//
// AutolayoutHelper.swift
//
// Created by Pawan on 30/07/19.
// Copyright © 2019 Pawan. All rights reserved.
//
import Foundation
@pawan-preet
pawan-preet / gist:8c7c2e7c7eb44cf5586a9d85700a7ecb
Created March 13, 2018 05:36
Get JSON String from a Dictionary
extension Dictionary {
var json: String {
let invalidJson = "Error: Invalid JSON"
do {
let jsonData = try JSONSerialization.data(withJSONObject: self, options: .prettyPrinted)
return String(bytes: jsonData, encoding: String.Encoding.utf8) ?? invalidJson
} catch {
return invalidJson
}
}