This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct PhotoListView: View { | |
| // 1 | |
| @StateObject var viewModel = PhotoListViewModel() | |
| var body: some View { | |
| NavigationView { | |
| List(viewModel.photoItems) { photoItem in | |
| // 2 | |
| ListItem(photoItem: photoItem) | |
| } | |
| .navigationTitle("Photo List") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func fetchPerson(by userId: String) async -> Person { | |
| do { | |
| // Tell compiler wait for the result with `await` keyword | |
| let (data, response) = try await URLSession.shared.data(from: <URL>) | |
| } catch { | |
| // ... | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| import AVFoundation | |
| enum CameraSession: Error { | |
| case inValidInput | |
| case inValidOutput | |
| } | |
| final class CameraSessionViewController: UIViewController { | |
| // Camera Setting |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Source: https://useyourloaf.com/blog/swiftui-custom-environment-values/ | |
| // 1. Create the key with a default value | |
| private struct CaptionColorKey: EnvironmentKey { | |
| static let defaultValue = Color(.secondarySystemBackground) | |
| } | |
| // 2. Extend the environment with our property | |
| extension EnvironmentValues { | |
| var captionBackgroundColor: Color { | |
| get { self[CaptionColorKey.self] } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| extension UIApplication { | |
| var currentKeyWindow: UIWindow? { | |
| UIApplication.shared.connectedScenes | |
| .filter { $0.activationState == .foregroundActive } | |
| .map { $0 as? UIWindowScene } | |
| .compactMap { $0 } | |
| .first?.windows | |
| .filter { $0.isKeyWindow } | |
| .first | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // https://www.jessesquires.com/blog/2018/11/17/executing-applescript-in-mac-app-on-macos-mojave/ | |
| private func runScript() { | |
| // Solution 1 | |
| let script = """ | |
| tell application "Notes" | |
| tell account "iCloud" | |
| make new note at folder "Notes" with properties {name:"14:53 Daily Notes", body:""} | |
| set noteRunTime to get notes whose name is "14:53 Daily Notes" | |
| show item 1 of noteRunTime |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // ContentView.swift | |
| // socket-demo | |
| // | |
| // Created by Erdem ILDIZ | |
| // | |
| import SwiftUI | |
| import SocketIO |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // CurrencyListModel.swift | |
| // socket-demo | |
| // | |
| // Created by Erdem ILDIZ | |
| // | |
| import Foundation | |
| // MARK: - CurrencyList |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import express from "express"; | |
| import { createServer } from "http"; | |
| import { Server } from "socket.io"; | |
| import fetch from "node-fetch"; | |
| const app = express(); | |
| const server = createServer(app); | |
| const io = new Server(server, { | |
| allowEIO3: true, | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| npm install |