Skip to content

Instantly share code, notes, and snippets.

@morteza2128
morteza2128 / AnyDecodable.swift
Last active May 28, 2021 13:55
AnyDecodable.swift
extension KeyedDecodingContainer {
typealias AnyDictionaryType = Dictionary<String, Any>.Type
typealias AnyArrayType = Array<Any>.Type
typealias AnyArrayOfDictionariesType = Array<Dictionary<String, Any>>.Type
// Decode Dictionary<String, Any>
func decode(_ type: AnyDictionaryType, forKey key: KeyedDecodingContainer<K>.Key) throws -> Dictionary<String, Any> {
let container = try self.nestedContainer(keyedBy: AnyCodingKeys.self, forKey: key)
return try container.decode(type)
class AppComponentConfig: ComponentConfig, Decodable {
var identifier: String = ""
var componentName: String = ""
var launchOnInit: Bool = false
var acceptPush: Bool = false
var urlScheme: String = ""
private enum CodingKeys: String, CodingKey {
@IBAction func signupButtonClicked(_ sender: UIButton) {
do {
try decideToSendSignupData()
SVProgressHUD.setDefaultMaskType(.gradient)
SVProgressHUD.show(withStatus: LoadingMessages.simple.localized )
self.serviceCore.sendSignUpRequet(email: self.emailTextField.text!, password: self.passTextField.text!)
}
@morteza2128
morteza2128 / MyDefaultColors.swift
Last active September 4, 2017 12:08
Use struct in Swift namespace
extension UIColor {
struct MyDefaultsColor {
private init(){}
static let Red = UIColor(red: 1.0, green: 0.1491, blue: 0.0, alpha: 1.0)
static let Green = UIColor(red: 0.0, green: 0.5628, blue: 0.3188, alpha: 1.0)
static let Blue = UIColor(red: 0.0, green: 0.3285, blue: 0.5749, alpha: 1.0)
}