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 numJewelsInStones(_ J: String, _ S: String) -> Int { | |
var counter = 0 | |
let stones = Array(S) | |
let jewels = Array(J) | |
for i in 0..<stones.count { | |
for j in 0..<jewels.count { | |
let lhs = stones[i] | |
let rhs = jewels[j] | |
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
extension UIImageView { | |
convenience init(named name: String, top: CGFloat, left: | |
CGFloat, bottom: CGFloat, right: CGFloat) { | |
let insets = UIEdgeInsetsMake(top, left, bottom, right) let originalImage = UIImage(named: name) | |
let insetImage = originalImage?.withAlignmentRectInsets(insets) self.init(image: insetImage) | |
} | |
} |
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
// | |
// PaneViewController.swift | |
// PaneApp | |
// | |
// Created by Vladyslav Bugrym on 18.02.2020. | |
// Copyright © 2020 admin. All rights reserved. | |
// | |
import UIKit |
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
@objc func adjustForKeyboard(notification: Notification) { | |
guard let keyboardValue = notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue else { return } | |
let keyboardScreenEndFrame = keyboardValue.cgRectValue | |
let keyboardViewEndFrame = view.convert(keyboardScreenEndFrame, from: view.window) | |
if notification.name == UIResponder.keyboardWillHideNotification { | |
scrollView.contentInset.bottom = self.logInButton.frame.height | |
} 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
private func buildTree(allProducts:[Product], handler: @escaping(()->Void)) { | |
let group = DispatchGroup() | |
let asyncQueue = DispatchQueue(label: "com.shop.tree.build.queue", qos: .utility, attributes: .concurrent, autoreleaseFrequency: .inherit, target: nil) | |
var byCategory:[ProductSection] = [] | |
group.enter() | |
asyncQueue.async { | |
for product in allProducts { |
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 | |
@UIApplicationMain | |
class AppDelegate: UIResponder, UIApplicationDelegate { | |
var window: UIWindow? | |
var coreDataStack = CoreDataStack() | |
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { | |
let navigationController = window?.rootViewController as! UINavigationController |
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 CoreData | |
class CoreDataStack { | |
// MARK: - Core Data stack | |
lazy var persistentContainer: NSPersistentContainer = { | |
/* | |
The persistent container for the application. This implementation | |
creates and returns a container, having loaded the store for the |
NewerOlder