Skip to content

Instantly share code, notes, and snippets.

View sabapathyk7's full-sized avatar
🍎
Apple Developer

Kanagasabapathy Rajkumar sabapathyk7

🍎
Apple Developer
View GitHub Profile
@sabapathyk7
sabapathyk7 / genericsexample.swift
Last active January 22, 2024 19:39
Generics and associatetype
import Foundation
/*
What is Generics in swift and how useful in the applications?
- Generics in swift allows flexible and reusable code that can work in different types while maintaining type safety
- Key Points are
- Type Safety,
- Reusability
- Parameterization
@sabapathyk7
sabapathyk7 / QoSGCD.swift
Created January 8, 2024 12:44
Basics of QoS - Swift - GCD
import Foundation
import PlaygroundSupport
PlaygroundPage.current.needsIndefiniteExecution = true
extension Date {
var currentTimeStamp: Int64 {
Int64(self.timeIntervalSince1970 * 1000)
}
}
func concurrency() {
@sabapathyk7
sabapathyk7 / AnyCancellableCombine.swift
Created December 30, 2023 07:43
AnyCancellable and Cancellable Example - Combine Framework
import Combine
import Foundation
import PlaygroundSupport
PlaygroundPage.current.needsIndefiniteExecution = true
// A simple publisher that emits integers from 1 to 5
let numberPublisher = [1, 2, 3, 4, 5].publisher
import Foundation
let sampleURL = URL(string: "https://example.com/auth-callback#access_token=mytoken&expires_in=36000&scope=zap+profile")
var sampleComponents = URLComponents()
sampleComponents.query = sampleURL?.fragment
for item in sampleComponents.queryItems! {
print("\(item.name): \(item.value)")
@sabapathyk7
sabapathyk7 / HigherOrder.swift
Created November 10, 2023 19:26
Higher Order Functions in Swift
// Created by kanagasabapathy on 11/10/23.
import Foundation
//: [Next](@next)
// Higher Order Functions
/*
@sabapathyk7
sabapathyk7 / ClosureExample.swift
Last active November 19, 2023 11:27
Unlocking Swift Closures: Code Blocks with Impact
import Foundation
/*
Closures are the self-contained blocks that can be passed around and used the code.
Capture the values and store a reference to any constants and variables
*/
/*