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 SwiftUI | |
| class SceneDelegate: UIResponder, UIWindowSceneDelegate { | |
| var window: UIWindow? | |
| func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { |
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 UIKit | |
| protocol Coordinator { | |
| var viewController: UIViewController? {get} | |
| var navigationController: UINavigationController? {get} | |
| func start() | |
| } |
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 tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | |
| let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) | |
| let item = items[indexPath.row] | |
| var content = cell.defaultContentConfiguration() | |
| content.image = UIImage(systemName: "star") | |
| content.text = "Hello!" | |
| cell.contentConfiguration = content |
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 fetchURLData<T: Decodable>(urlString: String, decodingType: T.Type) async throws -> T { | |
| guard let url = URL(string: urlString) else { | |
| throw URLError(.badURL) | |
| } | |
| let session = URLSession.shared | |
| let (data, response) = try await session.data(from: url) | |
| guard let httpResponse = response as? HTTPURLResponse, httpResponse.statusCode == 200 else { |
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 | |
| // let charactersURL = ApiService.character.url | |
| //output: url = https://rickandmortyapi.com/api/character | |
| // let url = ApiService.characterPage(19).url | |
| // output: url = https://rickandmortyapi.com/api/character/?page=19 | |
| enum ApiService { |
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 | |
| // cartographic-assistant | |
| // | |
| // Created by Harlock on 11/11/2023. | |
| // | |
| import SwiftUI | |
| struct ContentView: View { |
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
| // # Serial queue | |
| // Creating a custom serial queue with a specific label | |
| let customQueue = DispatchQueue(label: "com.example.myqueue") | |
| // Adding a task to the custom queue | |
| customQueue.sync { | |
| // Perform some work here | |
| } | |
| // # Concurrent queue |
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 | |
| extension CGFloat { | |
| static func random() -> CGFloat { | |
| return CGFloat(arc4random()) / CGFloat(UInt32.max) | |
| } | |
| } | |
| extension UIColor { | |
| static func random() -> UIColor { |
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
| // 1. Delete the Main.storyboard file from the project. Click Move to Trash. | |
| // 2. Remove Storyboard Name from File info.plist | |
| // 3. Go to Application Target -> Build Settings -> Find the line: UIKit Main Storyboard File Base Name and remove the name of the storyboard. | |
| // 4. In order to programmatically set the root controller of our application: | |
| // Go to SceneDelegate file and in the func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) method add the following code: | |
| import UIKit | |
| class SceneDelegate: UIResponder, UIWindowSceneDelegate { |
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
| // es6 ---- junio 2015 | |
| /** | |
| * -----------------------------------------------------------Default Params | |
| */ | |
| function newFunction(name, age, country) { | |
| var name = name || 'Oscar'; | |
| var age = age || 32; | |
| var country = country || 'MX'; | |
| console.log(name, age, country); | |
| } |
NewerOlder