Skip to content

Instantly share code, notes, and snippets.

View arashkashi's full-sized avatar
💭
Working with machines against the machine

A.K. arashkashi

💭
Working with machines against the machine
View GitHub Profile
@arashkashi
arashkashi / CurrentValueSubjectToBinding.swift
Created June 10, 2021 11:51 — forked from PaulWoodIII/CurrentValueSubjectToBinding.swift
Bindings over a CurrentValue subject allow you to use combine for side affects
//: [Previous](@previous)
import Foundation
import SwiftUI
import Combine
//: Current Value Subject is a value, a publisher and a subscriber all in one
let currentValueSubject = CurrentValueSubject<Bool, Never>(true)
print(currentValueSubject.value)
@arashkashi
arashkashi / secureAppStorageWrapper.swift
Created June 4, 2021 07:11
Make string and all coddles to keychain
//
// KeychainStorage+Wrapper.swift
// YTravel
//
// Created by Chandan Singh on 6/2/21.
//
import SwiftUI
struct KeychainItem {
@arashkashi
arashkashi / fixed_size_container.swift
Created June 2, 2021 07:01
layout of fixed size elements into a container (top leading)
//
// ContentView.swift
// ffghgf
//
// Created by Arash on 2021-06-02.
//
import SwiftUI
struct SizeArrayKey: PreferenceKey {
@arashkashi
arashkashi / geometry reader.swift
Last active May 27, 2021 22:10
swiftui get height of text and get the top unsafe height with grace
struct SizePreferenceKey: PreferenceKey {
typealias Value = CGSize?
static func reduce(value: inout CGSize?, nextValue: () -> CGSize?) {
value = value ?? nextValue()
}
}
struct ReportSize: View {
var base: Text
@arashkashi
arashkashi / ShareViewcontroller.swift
Created August 20, 2019 07:34
Add share controller
//
// TestViewController.swift
// Balance
//
// Created by ArashK on 2019-08-01.
// Copyright © 2019 Congruent Tech. UG. All rights reserved.
//
import UIKit
import CloudKit
@arashkashi
arashkashi / fetchcontrollerwithdatasource.swift
Created July 4, 2019 07:32
fetch controller with data source for swift
import UIKit
import CoreData
public protocol FetchedResultsDelegate {
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath, object: AnyObject) -> UITableViewCell
}
public class FetchedResultsDataSource: NSObject, UITableViewDataSource, NSFetchedResultsControllerDelegate {
public weak var tableView: UITableView?
@arashkashi
arashkashi / Composition.swift
Created June 26, 2019 20:58
More advanced serialization operator
infix operator --> :AdditionPrecedence
enum Result<T> {
case success(T)
case fail(Error)
}
func --><InA, InAEnv,OutAEnv ,OutBEnv , OutA, OutB>
(first: @escaping ( InAEnv? , InA , @escaping (OutAEnv?, Result<OutA>) -> () ) -> (),
second: @escaping (OutAEnv? , OutA, @escaping (OutBEnv?, Result<OutB>) -> () ) -> ()) ->
@arashkashi
arashkashi / OperationsPipeline.swift
Last active June 25, 2019 22:17
Pipeline operations
import UIKit
import Foundation
enum PipableOperationOutput<T> {
case success(T)
case fail(Error)
}
@arashkashi
arashkashi / Script.sh
Created June 13, 2019 12:55
Xcode build script for provisioning profile
#!/bin/bash
TARGET="Your App"
CONFIGURATION="Release"
SDK="iphoneos"
PROFILE_PATH="/Users/jkp/Desktop/foo.mobileprovision"
IDENTITY="iPhone Distribution: Your Company Ltd"
KEYCHAIN="/Users/jkp/Desktop/keychain"
PASSWORD="foobar"
@arashkashi
arashkashi / FetchResutlControllerWithCollectionView.swift
Created April 21, 2018 16:46
automatically sync collection view with.a fetch result controller.
//
// FetchResultsControllerWithCollectionView.swift
// CoreStore
//
// Created by Arash Kashi on 2/23/17.
// Copyright © 2017 Arash K. All rights reserved.
//
import Foundation
import CoreData
import UIKit