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
extension NSObject { | |
var className: String { | |
return String(describing: type(of: self)) | |
} | |
class var className: String { | |
return String(describing: self) | |
} | |
} |
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
extension UIViewController { | |
func configureChildViewController(childController: UIViewController, onView: UIView?) { | |
var holderView = self.view | |
if let onView = onView { | |
holderView = onView | |
} | |
addChildViewController(childController) | |
holderView?.addSubview(childController.view) | |
constrainViewEqual(holderView: holderView!, view: childController.view) | |
childController.didMove(toParentViewController: self) |
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
extension String { | |
static var documentsPath:String { | |
let paths = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask) | |
let documentsDirectory = paths[0] | |
return documentsDirectory.path | |
} | |
var filePathAtDocumentsDirectory:String { | |
let docPath = String.documentsPath |
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
guard let jsonDct:[String:Any] = readJsonFile() , let arrCategoriesDct:[[String:Any]] = jsonDct["categories"] as? [[String:Any]] else { return } | |
let categories:[Category] = arrCategoriesDct.compactMap { dct -> Category? in | |
return Category(dct: dct) | |
} | |
var completedCount:Int = 0 | |
categories.forEach { category in | |
self.asyncTask(imageURL: category.thumbnailImage, completion: { image in | |
completedCount += 1 | |
if completedCount == categories.count { |
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 group:DispatchGroup = DispatchGroup() | |
group.enter() // entryCount = 1 | |
iAmLongRunningFunc { | |
group.leave() // entryCount = 0 | |
} | |
group.enter() // entryCount = 1 | |
iAmLongRunningFunc { | |
group.leave() // entryCount = 0 |
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 UIKit | |
class ImageKit: NSObject { | |
private let group:DispatchGroup = DispatchGroup() | |
override init() { | |
super.init() | |
} | |