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
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0ul); | |
dispatch_async(queue, ^{ | |
NSURL *url = [NSURL URLWithString: @"http://upload.wikimedia.org/wikipedia/commons/7/7f/Williams_River-27527.jpg"]; | |
NSURLSessionDownloadTask *downloadPhotoTask = [[NSURLSession sharedSession] | |
downloadTaskWithURL:url completionHandler:^(NSURL *location, NSURLResponse *response, NSError *error) { | |
UIImage *downloadedImage = [UIImage imageWithData: | |
[NSData dataWithContentsOfURL:location]]; | |
}]; | |
[downloadPhotoTask resume]; | |
}); |
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
var localIdSet = Set<Int>() | |
var netIdSet = Set<Int>() | |
let idToDelete = localIdSet.subtracting(netIdSet) |
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
var localIdSet = Set<Int>() | |
var netIdSet = Set<Int>() | |
let idToDelete = localIdSet.subtracting(netIdSet) |
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 Node { | |
var visited = false | |
var connections: [Connection] = [] | |
} | |
class Connection { | |
public let to: Node | |
public let weight: Int | |
public init(to node: Node, weight: Int) { |
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
//98. Validate Binary Search Tree | |
class TreeNode { | |
var val: Int | |
var left: TreeNode? | |
var right: TreeNode? | |
init(_ val: Int) { | |
self.val = val | |
self.left = nil | |
self.right = 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
- (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]); |
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
// | |
// 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
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
let phones: [Phone] = [ | |
.init(model: "Samsung A3", manufacturer: "Samsung"), | |
.init(model: "iPhone 13", manufacturer: "Apple") | |
] | |
let phoneModels = phones.map(\.model) | |
OlderNewer