Apps used: Cursor.so / github copilot chat / Amazon Q / codeium
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 SwiftUI | |
| import UIKit | |
| struct ContentView: View { | |
| @State private var isLocked = false | |
| @State private var isSheetVisible = false | |
| var body: some View { | |
| LockableView(isLocked: isLocked) { |
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 Foundation | |
| import CoreData | |
| extension MyCoredataObject { | |
| @nonobjc public class func createFetchRequest() -> NSFetchRequest<MyCoredataObject> { | |
| return NSFetchRequest<MyCoredataObject>(entityName: "MyCoredataObject") | |
| } | |
| @NSManaged public var sortId: Int64 |
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 Alamofire | |
| func makeGetCallWithAlamofire() { | |
| let todoEndpoint: String = "https://jsonplaceholder.typicode.com/todos/1" | |
| Alamofire.request(todoEndpoint) | |
| .responseJSON { response in | |
| // check for errors | |
| guard response.result.error == nil else { | |
| // got an error in getting the data, need to handle it | |
| print("error calling GET on /todos/1") |
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 String { | |
| func unescapeHTMLEntities() throws -> String { | |
| guard contains("&#") else { | |
| return self | |
| } | |
| guard let data = data(using: .utf8) else { | |
| return 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
| function flatten(arr) { | |
| return arr.reduce((acc, val) => acc.concat(Array.isArray(val) ? flatten(val) : val), []); | |
| } |
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 Data { | |
| /** | |
| Consumes the specified input stream, creating a new Data object | |
| with its content. | |
| - Parameter reading: The input stream to read data from. | |
| - Note: Closes the specified stream. | |
| */ | |
| init(reading input: InputStream) { | |
| self.init() | |
| input.open() |
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
| // | |
| // Range+Extensions.swift | |
| // IntensityAttributingKit | |
| // | |
| // Created by Evan Mckee on 3/23/16. | |
| // Copyright © 2016 McKeeMaKer. All rights reserved. | |
| // | |
| import Foundation |
Using Swift Package Manager with iOS
File > New > Project...
Create a Package.swift file in your root project directory, add dependencies, then run swift package fetch on the command line in the same directory. We’re not going to run swift build because it will just complain.
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 | |
| let scoresStringArray : [String] = ["Mike","Tom","Bily"] | |
| let scoresDataArray = NSKeyedArchiver.archivedData(withRootObject: scoresStringArray) | |
| //Save data | |
| _ = Keychain.save(key: "scoresKey", data: scores) | |
| //Load data | |
| if Keychain.load(key: "scoresKey") != nil{ |
