Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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 UIColor { | |
convenience init(red: Int, green: Int, blue: Int) { | |
assert(red >= 0 && red <= 255, "Invalid red component") | |
assert(green >= 0 && green <= 255, "Invalid green component") | |
assert(blue >= 0 && blue <= 255, "Invalid blue component") | |
self.init(red: CGFloat(red) / 255.0, green: CGFloat(green) / 255.0, blue: CGFloat(blue) / 255.0, alpha: 1.0) | |
} | |
convenience init(rgb: Int) { |
This file contains 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
// | |
// NSManagedObject.swift | |
// | |
// Created by Marcos Santos on 8/30/18. | |
// Copyright © 2018 Marcos Santos 2018. All rights reserved. | |
// | |
import Foundation | |
import CoreData |
This file contains 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
// | |
// DataManager.swift | |
// | |
// Created by Marcos Santos on 8/30/18. | |
// Copyright © 2018 Marcos Santos 2018. All rights reserved. | |
// | |
import CoreData | |
public class DataManager { |
This file contains 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 showError(_ message: String?) { | |
let alert = UIAlertController(title: "Error", message: message, preferredStyle: .alert) | |
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil)) | |
self.present(alert, animated: true, completion: nil) | |
} | |
} |
This file contains 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 displaySpinner(onView : UIView) -> UIView { | |
let spinnerView = UIView.init(frame: onView.bounds) | |
spinnerView.backgroundColor = UIColor.white //UIColor.black.withAlphaComponent(0.5) | |
let ai = UIActivityIndicatorView(style: .gray) | |
ai.startAnimating() | |
ai.center = spinnerView.center | |
DispatchQueue.main.async { | |
spinnerView.addSubview(ai) |
This file contains 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 UIImageView { | |
//Use this function with the imageview | |
func loadImageUsingCacheWithUrlString(_ url: String?) { | |
guard let url = url else { | |
self.image = UIImage(named: "default") | |
return | |
} | |
let imageName = url.split(separator: "/").last! as NSString | |
let fileManager = FileManager.default |
This file contains 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
var timeString: String { | |
let formatter = DateComponentsFormatter() | |
formatter.allowedUnits = [.month, .day, .hour, .minute] | |
formatter.unitsStyle = .abbreviated | |
formatter.zeroFormattingBehavior = .dropAll | |
if let date = self.date, let interval = formatter.string(from: date, to: Date()) { | |
return "\(interval) ago" | |
} | |
return "unknown" |
OlderNewer