Skip to content

Instantly share code, notes, and snippets.

André Souza andrehsouza

View GitHub Profile
View accessibility_notification.swift
// Request .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
View accessibility_properties.swift
// UICollectionViewCell
isAccessibilityElement = true
accessibilityTraits = .button
accessibilityLabel = "\(job.title). \(L10n.jobLocation): \(job.location)"
accessibilityHint = L10n.jobCellHint
View accessibility_font.swift
// UILabel
label.font = .preferredFont(forTextStyle: .headline)
label.adjustsFontForContentSizeCategory = true
// UIImageView
imageView.adjustsImageSizeForAccessibilityContentSizeCategory = true
View Example4.swift
let customerList = Customer.fetchAll()
View Example3.swift
let customer = Customer() = "Mike" = ""
customer.password = "mike123"
View NSObject+Extension.swift
import Foundation
protocol DescribeProtocol: class { }
extension DescribeProtocol where Self: NSObject {
static var objectName: String {
return String(describing: self)
View Customer.swift
import Foundation
import CoreData
class Customer: CustomNSManagedObject, FetchableProtocol {
@NSManaged var name: String
@NSManaged var email: String
@NSManaged var password: String
View CustomNSManagedObject.swift
import Foundation
import CoreData
protocol FetchableProtocol: class {
associatedtype FetchableType: NSManagedObject = Self
extension FetchableProtocol where Self : NSManagedObject, FetchableType == Self {
static func fetchAll() -> [FetchableType] {
View CoreDataStack.swift
import UIKit
import CoreData
//MARK: - Core Data stack
class CoreDataStack: NSObject {
static let sharedInstance = CoreDataStack()
static let containerName = "CoreDataExample" //CoreDataExample.xcdatamodeld
private override init() {}
You can’t perform that action at this time.