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 Car { | |
let gears: [Gear] | |
} | |
struct Gear { | |
let name: String | |
} | |
let firstGearKeyPath = \Car.gears[0].name |
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 Size { | |
var width: Int // Changed to var | |
let height: Int | |
} | |
struct Table { | |
var size: Size // Changed to var | |
let material: String | |
} |
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 tableSizeKeyPath = \Table.size.width // KeyPath<Table, Int> | |
let tableMaterialKeyPath = \Table.material // KeyPath<Table, String> | |
let table = Table( | |
size: .init(width: 100, height: 20), | |
material: "wood" | |
) | |
print(table[keyPath: tableSizeKeyPath]) // 100 |
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 Size { | |
let width: Int | |
let height: Int | |
} | |
struct Table { | |
let size: Size | |
let material: String | |
} |
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 Size { | |
let width: Int | |
let height: Int | |
} | |
struct Table { | |
let size: Size | |
let material: String | |
} |
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 phones: [Phone] = [ | |
.init(model: "Samsung A3", manufacturer: "Samsung"), | |
.init(model: "iPhone 13", manufacturer: "Apple") | |
] | |
let phoneModels = phones.map(\.model) | |
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 basicAnimation = CABasicAnimation(keyPath: "bounds") |
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
// | |
// CircularProgressBarViewController.swift | |
// iOS_CoreAnimation_Advanced_practice | |
// | |
// Created by Anton Makarenkov on 08/08/2020. | |
// Copyright © 2020 Anton Makarenkov. All rights reserved. | |
// | |
import UIKit |
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
final class SharedTokenManager { | |
private let tokenKey = "token" | |
private let accessGroup: String | |
init(accessGroup: String) { | |
self.accessGroup = accessGroup | |
} | |
func getToken() -> String? { |
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
- (void)applicationDidEnterBackground:(UIApplication *)application | |
{ | |
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. | |
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. | |
NSLog(@"%s", __FUNCTION__); | |
__block UIBackgroundTaskIdentifier task = [application beginBackgroundTaskWithExpirationHandler:^{ | |
NSLog(@"Expiration handler called %f",[application backgroundTimeRemaining]); |