Skip to content

Instantly share code, notes, and snippets.

View Rsych's full-sized avatar
🙈
I may be slow to respond.

J. W. Kim Rsych

🙈
I may be slow to respond.
View GitHub Profile
@Rsych
Rsych / CoinDataService.swift
Last active January 19, 2022 19:51
DataService
import Foundation
import Combine
class CoinDataService {
@Published var allCoins: [Coin] = []
var subscription: AnyCancellable?
init() {
getCoins()
@Rsych
Rsych / NetworkManager.swift
Last active January 19, 2022 19:51
NetworkManager
import Foundation
import Combine
class NetworkManager {
enum NetworkingError: LocalizedError {
case badURLResponse(url: URL)
case unknown
var errorDescription: String? {
@Rsych
Rsych / CustomTabContent.swift
Created December 13, 2021 14:14
Custom Tab bar content
struct ContentView: View {
// MARK: - Properties
@State private var selectedTab = 0
// MARK: - Body
var body: some View {
TabView(selection: $selectedTab) {
HomeView()
.tag(0)
Text("Open")
@Rsych
Rsych / CustomTabBar.swift
Created December 13, 2021 14:13
SwiftUI custom Tab bar
import SwiftUI
struct TabBarView: View {
// MARK: - Properties
@Binding var selectedTab: Int
@Namespace private var currentTab
// MARK: - Body
var body: some View {
HStack {
ForEach(tabs.indices) { index in
@Rsych
Rsych / GoogMapView.swift
Created December 12, 2021 11:07
Google Map View
//
// GoogMapView.swift
// Landmarks
//
//
import SwiftUI
import UIKit
import GoogleMaps
import GooglePlaces
@Rsych
Rsych / PlacePicker.swift
Created December 12, 2021 10:59
GooglePlaces picker
import Foundation
import UIKit
import SwiftUI
import GooglePlaces
struct PlacePicker: UIViewControllerRepresentable {
func makeCoordinator() -> Coordinator {
Coordinator(self)
@Rsych
Rsych / JSONParser.swift
Created December 8, 2021 08:02
Swift JSON parser with dynamicMemberLookup
@dynamicMemberLookup
struct JSON: RandomAccessCollection {
var value: Any?
var startIndex: Int { array.startIndex }
var endIndex: Int { array.endIndex }
init(string: String) throws {
let data = Data(string.utf8)
value = try JSONSerialization.jsonObject(with: data)
}
@Rsych
Rsych / XMLParser.swift
Created December 8, 2021 07:15
Swift XML parser
class XMLNode {
let tag: String
var data: String
let attributes: [String: String]
var childNodes: [XMLNode]
init(tag: String, data: String, attributes: [String: String], childNodes: [XMLNode]) {
self.tag = tag
self.data = data
self.attributes = attributes
@Rsych
Rsych / modifyRecordsResultBlock.swift
Created December 6, 2021 07:07
modifyRecordsCompletionBlock depreciated use modifyRecordsResultBlock
.toolbar {
Button {
let records = project.prepareCloudRecords()
let operation = CKModifyRecordsOperation(recordsToSave: records, recordIDsToDelete: nil)
operation.savePolicy = .allKeys
operation.modifyRecordsResultBlock = { result in
switch result {
case .success:
print("Success")
case .failure(let error):
@Rsych
Rsych / WidgetLink.swift
Created December 5, 2021 15:00
Link widget items using Link(...