Skip to content

Instantly share code, notes, and snippets.

View IronLeash's full-sized avatar

Ilker Baltaci IronLeash

  • ThinxNet
  • München
View GitHub Profile
@IronLeash
IronLeash / CustomCache.swift
Created March 30, 2021 11:59
CustomCache.swift
//
// CustomCache.swift
//
// Created by Ilker Baltaci on 16.06.20.
//
import Foundation
public final class CustomCache<Key: Hashable, Value> {
@IronLeash
IronLeash / RegisterUnregister.swift
Last active June 9, 2020 12:10
RegisterUnregister.swift
//To register as delegate
AuthenticationManager.sharedInstace.multicastDelegate.add(self)
//To unregister
AuthenticationManager.sharedInstace.multicastDelegate.remove(self)
protocol AuthenticationManagerDelegate: class {
func userDidLogout()
func userDidLogin(_ user: User)
}
@objc class AuthenticationManager: NSObject {
static let sharedInstace = AuthenticationManager()
public var user: User?
class MulticastDelegate<T> {
private let delegates: NSHashTable<AnyObject> = NSHashTable.weakObjects()
func add(_ delegate: T) {
delegates.add(delegate as AnyObject)
}
func remove(_ delegateToRemove: T) {
for delegate in delegates.allObjects.reversed() {
-(void)configDatePicker:(UIDatePicker *)datePicker{
datePicker.backgroundColor = [UIColor whiteColor];
// Round Default date with 15 mins interval
NSDateComponents *dateComponents = [[NSCalendar currentCalendar] components:NSMinuteCalendarUnit fromDate:[NSDate date]];
NSInteger minutes = [dateComponents minute];
NSInteger minutesRounded =roundf((float)minutes / (float)30 + 0.5) * 30;
NSDate *roundedDate = [[NSDate alloc] initWithTimeInterval:60.0 * (minutesRounded - minutes) sinceDate:[NSDate date]];
[datePicker setMinimumDate:roundedDate];