This file contains 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
// | |
// MyNotificationCenter.swift | |
// MyNotificationCenterImplementation | |
// | |
// Created by Jayesh Kawli on 10/12/19. | |
// Copyright © 2019 Jayesh Kawli. All rights reserved. | |
// | |
import Foundation | |
enum NotificationCenterError: Error { |
This file contains 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
// | |
// TransactionOperation.swift | |
// NotificationCenterImplementation | |
// | |
// Created by Jayesh Kawli on 10/18/20. | |
// Copyright © 2020 Jayesh Kawli. All rights reserved. | |
// | |
import Foundation |
This file contains 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
let graphNodes = [(1, 2), (2, 3), (2, 4), (4, 5), (4, 6), (5, 4)] | |
var nodeToIncomingEdgesCountMapping: [Int: Int] = [:] | |
for node in graphNodes { | |
if nodeToIncomingEdgesCountMapping[node.0] == nil { | |
nodeToIncomingEdgesCountMapping[node.0] = 0 | |
} | |
if nodeToIncomingEdgesCountMapping[node.1] == nil { |
This file contains 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 Employee: Codable { | |
let name: String | |
let ssn: String | |
} | |
private let employeeDataKey = "employee" | |
func encodeObject() { | |
do { | |
let employeeData = try JSONEncoder().encode(Employee(name: "abc def", ssn: "123456789")) |
This file contains 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 | |
struct ShadowView: View { | |
let xOffset: CGFloat | |
let yOffset: CGFloat | |
var body: some View { | |
Text("SwiftUI is Awesome").padding().background( | |
Rectangle() |
This file contains 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 | |
struct ShadowComponent: View { | |
enum Direction { | |
case upward | |
case downward | |
This file contains 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 | |
extension VerticalAlignment { | |
// A custom vertical alignment to custom align views vertically | |
private struct TopSectionTitlesAlignment: AlignmentID { | |
static func defaultValue(in context: ViewDimensions) -> CGFloat { | |
// Default to center alignment if no guides are set | |
context[HorizontalAlignment.center] | |
} |
This file contains 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
class ViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
findMatches() | |
findMatchingElements() | |
replaceMatchingElements() | |
} | |
func findMatches() { |
This file contains 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 | |
struct Place: Identifiable { | |
let id: String | |
let name: String | |
let imageName: String | |
var isFavorited: Bool = false | |
} |
This file contains 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
// Searchable.swift | |
import SwiftUI | |
struct Searchable: View { | |
@State var searchText: String = "" | |
private let suggestions = ["Milan", "Rome", "Paris", "Iceland", "Greenland", "Florida"] |