Skip to content

Instantly share code, notes, and snippets.

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

Dimo Hamdy dimohamdy

🏠
Working from home
View GitHub Profile
let jsonString = """
{
"id": 1,
"name": "yearly.plan",
"display_name": "الباقة اليومية",
"payment_method_key": "1",
"number_of_days": "35",
"payment_method_id": 3
}
"""
let realm = try! Realm()
let plan = realm.objects(Plan.self)
try! realm.write {
realm.delete(plan)
}
CLSLogv("Log awesomeness %d %d %@", getVaList([1, 2, "three"]))
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
// Use Firebase library to configure APIs
FirebaseApp.configure()
//get remote config from firebase
LoginConfigManager.shared.getData()
return true
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var label: UILabel!
@IBOutlet weak var button: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
label.isHidden = LoginConfigManager.shared.config?.showLabel ?? false
@dimohamdy
dimohamdy / LoginConfig.swift
Created January 15, 2019 12:58
LoginConfig Model
//
// LoginConfig.swift
//
// Create by Ahmed Tawfik on 15/1/2019
// Copyright © 2019. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
struct LoginConfig : Codable {
@dimohamdy
dimohamdy / LoginConfigManager.swift
Last active January 15, 2019 16:48
fetch config from firbase
import Firebase
class LoginConfigManager {
static let shared = LoginConfigManager()
var config:LoginConfig? = nil
func getData() {
let remoteConfig = RemoteConfig.remoteConfig()
@dimohamdy
dimohamdy / Operation.swift
Created January 6, 2019 19:20
using AsyncOperation
import AsyncOperation
let op1 = AsyncBlockOperation() { operation in
operation.state = .executing
let urlString = URL(string: "http://jsonplaceholder.typicode.com/users/1")
if let url = urlString {
let task = URLSession.shared.dataTask(with: url) { (data, response, error) in
if error != nil {
print(error)
@dimohamdy
dimohamdy / Operation.swift
Created January 6, 2019 13:28
add aDependency between operations
let queue = OperationQueue()
queue.maxConcurrentOperationCount = 1
op3.addDependency(op2)
op2.addDependency(op1)
queue.addOperations([op1,op2,op3], waitUntilFinished: true)
let queue = OperationQueue()
queue.maxConcurrentOperationCount = 1
queue.addOperations([op1,op2,op3], waitUntilFinished: true)