Skip to content

Instantly share code, notes, and snippets.

View lugearma's full-sized avatar

Luis Arias lugearma

  • México
View GitHub Profile
@lugearma
lugearma / AlertPresentable.swift
Created February 4, 2019 17:29
Presenting alert from POP perspective
import UIKit
struct AlertActionComponent {
var title: String
var style: UIAlertAction.Style
var handler: ((UIAlertAction) -> Void)?
init(title: String, style: UIAlertAction.Style = .default, handler: ((UIAlertAction) -> Void)?) {
self.title = title
self.style = style
extension String {
func toDate(withFormat format: String = "yyyy-MM-dd") -> Date {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = format
guard let date = dateFormatter.date(from: self) else {
preconditionFailure("Take a look to your format")
}
return date
}
}
struct State {
let name: String
init(name: String) {
self.name = name
}
}
extension State: ExpressibleByStringLiteral {
@lugearma
lugearma / StringToDate.swift
Created September 29, 2017 18:06
Convert String Date format to Date Type
import Foundation
let start = "2017-05-25"
let end = "2017-11-12"
let dateFormat = "yyyy-MM-dd"
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = dateFormat
let startDate = dateFormatter.date(from: start)
import UIKit
let feedCellId = "feedCellId"
class FeedViewController: UICollectionViewController {
override func viewDidLoad() {
super.viewDidLoad()
self.collectionView!.backgroundColor = UIColor.whiteColor()
@lugearma
lugearma / app_.gitignore
Created December 20, 2014 18:11
Primer comit
/build