This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// CustomCache.swift | |
// | |
// Created by Ilker Baltaci on 16.06.20. | |
// | |
import Foundation | |
public final class CustomCache<Key: Hashable, Value> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//To register as delegate | |
AuthenticationManager.sharedInstace.multicastDelegate.add(self) | |
//To unregister | |
AuthenticationManager.sharedInstace.multicastDelegate.remove(self) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol AuthenticationManagerDelegate: class { | |
func userDidLogout() | |
func userDidLogin(_ user: User) | |
} | |
@objc class AuthenticationManager: NSObject { | |
static let sharedInstace = AuthenticationManager() | |
public var user: User? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(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]; |