Skip to content

Instantly share code, notes, and snippets.

View ham118's full-sized avatar
:octocat:

Harsh M. ham118

:octocat:
View GitHub Profile
@heestand-xyz
heestand-xyz / image-resize.swift
Last active November 20, 2019 07:04
Image Resize - Aspect Fit / Fill
public enum ImagePlacement {
case fill
case fit
}
public static func resize(_ image: UIImage, to size: CGSize, placement: ImagePlacement = .fill) -> UIImage {
let frame: CGRect
switch placement {
case .fit:
@SheldonWangRJT
SheldonWangRJT / Map, FlatMap (CompactMap), Reduce, Filter & Sort.md
Last active March 21, 2022 20:04
Swift Map, FlatMap (CompactMap), Reduce, Filter & Sort

High Order Functions in iOS Swift

Written by Sheldon, please find me with #iOSBySheldon in Github, Youtube, Facebook, etc.

It is exaggerating to say we don't need to use for loop or while loop any more but we can take advantage of the Swift language built in functions to do loops. If I give you a question now. Q: Assuming we have an optional nested array, please calculate the production of the values that are less than 5. let numbers: [[Int]?] = [[1, 3], nil, [2], [5, 10], nil, [4]], what is your best approach to do it?

And you know the solution that I am talking about is following Swift functions:

  1. Map
  2. FlatMap / CompactMap
@fxm90
fxm90 / WebViewExampleViewController.swift
Last active June 17, 2023 01:18
Show progress of WKWebView in UIProgressBar that is attached to an UINavigationBar
//
// WebViewExampleViewController.swift
//
// Created by Felix Mau on 06.01.18.
// Copyright © 2018 Felix Mau. All rights reserved.
//
import UIKit
import WebKit