Skip to content

Instantly share code, notes, and snippets.

@BestKora
BestKora / BottomSheet.swift
Last active Mar 21, 2020
Control vertical move of the ScrollView in SwiftUI.
View BottomSheet.swift
import SwiftUI
import Combine
public struct BottomSheet<Content>: View where Content : View {
/// The content of the scroll view.
public var content: Content
/// The offset of the scrollview updated as the scroll view scrolls
@Binding public var offset : CGSize
@BestKora
BestKora / FunctionalJSON.playground.swift
Last active Aug 29, 2015
Код к статье Chris Eidhof "JSON parsing in Swift" http://chris.eidhof.nl/posts/json-parsing-in-swift.html с улучшенной функцией печати на Playground.
View FunctionalJSON.playground.swift
// This code accompanies a blog post: http://chris.eidhof.nl/posts/json-parsing-in-swift.html
//
// As the >>= operator is already defined, so I changed it to >>>=
import Foundation
let parsedJSON : [String:AnyObject] = [
"stat": "ok",
"blogs": [
@BestKora
BestKora / FunctionalSwift.playground.swift
Last active Aug 29, 2015
Код к выступлению Chris Eidhof на встрече SLUG группы http://realm.io/news/functional-programming-swift-chris-eidhof/
View FunctionalSwift.playground.swift
// This code accompanies a Swift meetup video on Realm: http://realm.io/news/functional-programming-swift-chris-eidhof/
//
// As the >>= operator is already defined, so I changed it to >>>=
import Foundation
let parsedJSON : [String:AnyObject] = [
"stat": "ok",
"blogs": [
View TrailingClosure.playground.swift
// Playground - noun: a place where people can play
import Foundation
import UIKit
//~~~~~~~~~~~~~~~~ Error handling with enum Result<A> ~~~~~~~
enum Result<A> {
case Error(NSError)
case Value(Box<A>)
View ViewController.swift
extension String {
func toEnum<Enum: RawRepresentable where Enum.RawValue == String>() -> Enum? {
return Enum(rawValue: self)
}
}
class ViewController: UIViewController {
.............
@BestKora
BestKora / EfficientJSON.playground.swift
Last active Aug 29, 2015
Код к статье "Эффективный JSON с функциональными концепциями и дженериками в Swift" http://www.bestkora.com/SwiftLearning/effektivnyj-json-v-swift-s-funtsionalnymi-kontseptsiyami-i-dzhenerikami/
View EfficientJSON.playground.swift
// Playground - noun: a place where people can play
import Foundation
/*let parsedJSON : [String:AnyObject] = [
"id": 1,
"name": "Cool User",
"email": "u.cool@example.com"
]
@BestKora
BestKora / ErrorHandling.playground.swift
Last active Aug 29, 2015
Код к серии статей "Управление ошибками в Swift: магия и реальность. http://www.bestkora.com/SwiftLearning/upravlenie-oshibkami-v-swift-magiya-i-realn/
View ErrorHandling.playground.swift
// Playground - noun: a place where people can play
import Foundation
// ДЛЯ СТАТЬИ http://nomothetis.svbtle.com/error-handling-in-swift
// Управление ошибками в Swift: магия и реальность - Часть 2
// http://www.bestkora.com/SwiftLearning/upravlenie-oshibkami-v-swift-magiya-i-realn/
// ============= Обычная функция ===========
func divide0 (a: Float, by: Float ) -> Float {