Skip to content

Instantly share code, notes, and snippets.

View andeeliao's full-sized avatar

Andee Liao andeeliao

  • dreamhaus
  • Shenzhen
View GitHub Profile
@andeeliao
andeeliao / Optional+Extension
Created December 24, 2023 03:54
is not nil check
extension Optional {
var isNotNil: Bool {
return self != nil
}
}
@andeeliao
andeeliao / MVVM.swift
Created December 11, 2023 01:38
MVVM protocols setup for swift ios project
//
// MVVM.swift
// ios-app
//
// Created by xue qi liao on 9/28/23.
//
// FIXME: this entire protocol stack needs to be related, as in ONE set of MVVM should be
// related and we shouldn't be passing unrelated Models to unrelated ViewModels or Views
// but that is beyond the scope of MVP
@andeeliao
andeeliao / UIButton+extensions
Created September 19, 2019 22:18
adding any uiview as a uibutton state
extension UIView {
var image: UIImage {
let renderer = UIGraphicsImageRenderer(bounds: bounds)
return renderer.image { rendererContext in
layer.render(in: rendererContext.cgContext)
}
}
}
extension UIButton {
func setBackgroundView(_ view: UIView, for state: UIControl.State) {
@andeeliao
andeeliao / ComparisonResult reversal
Created August 15, 2019 18:20
reverse comparison
extension ComparisonResult {
func reversed() -> ComparisonResult {
switch self {
case .orderedAscending:
return .orderedDescending
case .orderedDescending:
return .orderedAscending
case .orderedSame:
return .orderedSame
}