Skip to content

Instantly share code, notes, and snippets.

View andrehsouza's full-sized avatar

André Souza andrehsouza

View GitHub Profile
// Request
UIAccessibility.post(notification: .layoutChanged,
argument: "Loading job list.")
spinner.isHidden = false
service.getJobList() { [weak self] result in
self?.spinner.isHidden = true
switch result {
case .success(let jobs):
self?.jobList = jobs
self?.tableView.reloadData()
// UICollectionViewCell
isAccessibilityElement = true
accessibilityTraits = .button
accessibilityLabel = "\(job.title). \(L10n.jobLocation): \(job.location)"
accessibilityHint = L10n.jobCellHint
view.accessibilityIgnoresInvertColors = true
// UILabel
label.font = .preferredFont(forTextStyle: .headline)
label.adjustsFontForContentSizeCategory = true
// UIImageView
imageView.adjustsImageSizeForAccessibilityContentSizeCategory = true
lazy var persistentContainer: NSPersistentContainer = {
let container = NSPersistentContainer(name: "CoreDataExample")
container.loadPersistentStores(completionHandler: { (storeDescription, error) in
if let error = error as NSError? {
fatalError("Unresolved error \(error), \(error.userInfo)")
}
})
return container
}()
let customerList = Customer.fetchAll()
let customer = Customer()
customer.name = "Mike"
customer.email = "mike@gmail.com"
customer.password = "mike123"
import Foundation
import CoreData
@objc(Customer)
class Customer: CustomNSManagedObject, FetchableProtocol {
@NSManaged var name: String
@NSManaged var email: String
@NSManaged var password: String
import Foundation
import CoreData
protocol FetchableProtocol: class {
associatedtype FetchableType: NSManagedObject = Self
}
extension FetchableProtocol where Self : NSManagedObject, FetchableType == Self {
static func fetchAll() -> [FetchableType] {
import Foundation
protocol DescribeProtocol: class { }
extension DescribeProtocol where Self: NSObject {
static var objectName: String {
return String(describing: self)
}
}