Skip to content

Instantly share code, notes, and snippets.

View mehdi-S's full-sized avatar
🍤

msilini mehdi-S

🍤
  • Paris
View GitHub Profile
@mehdi-S
mehdi-S / AsyncButton.swift
Created February 24, 2024 12:53
Implementation of a button that shows the loading state of an async function passed in param
//
// AsyncButton.swift
// WeaMap
//
// Created by msilini on 24/02/2024.
//
import SwiftUI
struct AsyncButton<Label: View>: View {
@mehdi-S
mehdi-S / flattenArray.swift
Last active April 8, 2018 17:26
Swift code that flatten nested integer array for job application at citrusByte (you can exec this code and play with value in Xcode Playground)
import Foundation
// nestedArrays will be a sample case to test our function
var nestedArrays = [[1,2,[3,[4,5]]],6] as [Any]
func flattenArray(nestedArrays array: [Any]) -> [Int]{
var newArray = [Int]()
array.forEach { item in
// recursively check is array item is an array, if so, pass it to flattenArray func
if let arrayItem = item as? [Any] {