Skip to content

Instantly share code, notes, and snippets.

André Souza andrehsouza

Block or report user

Report or block andrehsouza

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View accessibility_notification.swift
// 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()
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()
customer.name = "Mike"
customer.email = "mike@gmail.com"
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
@objc(Customer)
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.