Skip to content

Instantly share code, notes, and snippets.

View erdemildiz's full-sized avatar
🏠
Working from home

Erdem ILDIZ erdemildiz

🏠
Working from home
View GitHub Profile
@erdemildiz
erdemildiz / pod-run.sh
Last active December 23, 2021 19:56
Pod run
pod install
@erdemildiz
erdemildiz / socket-pod-file.rb
Created December 23, 2021 19:44
Socket pod file
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'socket-demo' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
pod 'Socket.IO-Client-Swift', '~> 15.2.0'
# Pods for socket-demo
end
@erdemildiz
erdemildiz / pod-install.sh
Last active December 23, 2021 19:48
pod install
pod init
@erdemildiz
erdemildiz / node-version.sh
Last active December 23, 2021 19:55
node-version
node -v
// v14.16.0
@erdemildiz
erdemildiz / uıview+animation.swift
Created December 3, 2021 19:33
UIView+Animation
// Source: https://medium.com/nice-photon-ios/animator-easy-trick-to-make-uikit-animations-reusable-2d10713ca3a
struct Animator {
typealias Animations = () -> ()
typealias Completion = (Bool) -> ()
let perform: (@escaping Animations, Completion?) -> ()
}
extension UIView {
static func animate(with animator: Animator, animations: @escaping () -> (), completion: ((Bool) -> ())? = nil) {
import Combine
@propertyWrapper
struct UserDefault<Value> {
let key: String
let defaultValue: Value
var container: UserDefaults = .standard
private let publisher = PassthroughSubject<Value, Never>()
var wrappedValue: Value {
//
// MapViewController.swift
// sampleApp
//
// Created by Erdem ILDIZ on 4.11.2021.
//
import UIKit
import MapKit
infix operator ++
func ++(initialText: String, nextText: String) -> String {
initialText + " " + nextText
}
// Usage
let combinedName = names.reduce("", ++)
// Result
// My name is Tom
// 1. Method
let combinedName = names.reduce(""){ initialText, nextName in "\(initialText) \(nextName)"}
// 2. Method
let combinedName = names.reduce("", +)
// 3. Method
let combinedName = numbers.reduce("") { $0 + $1 }
// Result
let names = ["My", "name", "is", "Tom"]