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
| import Foundation | |
| import Alamofire | |
| class Connectivity { | |
| class func isConnectedToInternet() ->Bool { | |
| return NetworkReachabilityManager()!.isReachable | |
| } | |
| } |
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
| extension UIStoryboard { | |
| class func viewController(identifier: String) -> UIViewController { | |
| return UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: identifier) | |
| } | |
| } |
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
| import IQKeyboardManagerSwift | |
| { | |
| func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { | |
| IQKeyboardManager.sharedManager().enable = true | |
| } | |
| } |
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
| extension UIImage { | |
| public func base64(format: ImageFormat) -> String? { | |
| var imageData: Data? | |
| switch format { | |
| case .png: imageData = UIImagePNGRepresentation(self) | |
| case .jpeg(let compression): imageData = UIImageJPEGRepresentation(self, compression) | |
| } | |
| return imageData?.base64EncodedString() | |
| } |
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
| extension Date { | |
| var ticks: UInt64 { | |
| return UInt64((self.timeIntervalSince1970 ) * 1000) | |
| } | |
| } |
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
| // | |
| // DateCollectionViewCell.swift | |
| // DateTimePicker | |
| // | |
| // Created by Fakiho on 01/01/18. | |
| // Copyright © 2018 fakiho.com </>. All rights reserved. | |
| // | |
| import UIKit |
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
| guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else { return } | |
| // Should remove all subsequent view controllers from memory. | |
| appDelegate.window?.rootViewController?.dismiss(animated: true, completion: nil) | |
| // Set the root view controller to a new instance of the sign in view controller. | |
| appDelegate.window?.rootViewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "animated") |
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
| extension UIViewController { | |
| func setupViewResizerOnKeyboardShown() { | |
| NotificationCenter.default.addObserver(self, | |
| selector: #selector(UIViewController.keyboardWillShowForResizing), | |
| name: Notification.Name.UIKeyboardWillShow, | |
| object: nil) | |
| NotificationCenter.default.addObserver(self, | |
| selector: #selector(UIViewController.keyboardWillHideForResizing), | |
| name: Notification.Name.UIKeyboardWillHide, | |
| object: nil) |
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
| func showNoConnectionAlert(_ messgae: String = "No connection, please make sure you have an internet access", _ Title: String = "No Connection", action: (() -> Void)?){ | |
| OperationQueue.main.addOperation { | |
| let alert = UIAlertController(title: Title, message: messgae, preferredStyle: .alert) | |
| let actionLocalized = NSLocalizedString("Settings", comment: "") | |
| let settingAction: UIAlertAction = UIAlertAction(title: actionLocalized, style: .default) { actions -> Void in action?()} | |
| alert.addAction(settingAction) | |
| UIApplication.topViewController()?.present(alert, animated: true, completion: nil) | |
| } | |
| } |
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 exapmpe: UIViewController,UIPopoverPresentationControllerDelegate { | |
| @IBAction func pressMe(_sender : UIButton){ | |
| let popController = UIStoryboard(name: "StoryBoardMain", bundle: nil).instantiateViewController(withIdentifier: "example") | |
| popController.modalPresentationStyle = UIModalPresentationStyle.popover | |
| popController.popoverPresentationController?.permittedArrowDirections = UIPopoverArrowDirection.up | |
| popController.popoverPresentationController?.delegate = self | |
| popController.popoverPresentationController?.sourceView = sender | |
| popController.popoverPresentationController?.sourceRect = sender.bounds | |
| self.present(popController, animated: true, completion: nil) |
NewerOlder