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
// example to show how to check if core data can infers a mapping model by itself | |
// do not forget to add the .momd to you model object package!!!! | |
// https://developer.apple.com/documentation/coredata/nsmappingmodel/1506468-inferredmappingmodelforsourcemod | |
// SWIFT 4 | |
if let previousModelURL = Bundle.main.url(forResource: "YOURMODELNAME.momd/YOURMODELVERSION 2", withExtension: "mom"), | |
let previousModel = NSManagedObjectModel(contentsOf: previousModelURL), | |
let currentModelURL = Bundle.main.url(forResource: "YOURMODELNAME.momd/YOURMODELVERSION 3", withExtension: "mom"), | |
let currentModel = NSManagedObjectModel(contentsOf: currentModelURL) { | |
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
// | |
// CoreDataStackTheOldWay.swift | |
// CoreDataShowcase | |
// | |
// Created by Barbara Rodeker on 24.09.17. | |
// | |
// THIS CLASS CONTAINS PROPERTIES THAT NEEDED TO BE | |
// CREATED FOR CORE DATA BEFORE THE EXISTENCE OF NSPERSISTENTCONTAINER (added in iOS10) | |
// | |
// SWIFT 4 |
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
// | |
// CoreDataStack.swift | |
// CoreDataShowcase | |
// | |
// Created by Barbara Rodeker on 31.10.17. | |
// | |
// THIS CLASS CONTAINS ALL THE REQUIRED PROPERTIES THAT NEED TO BE CREATED | |
// FOR CORE DATA AFTER NSPersistentContainer was added in IOS 10 | |
// | |
// SWIFT 4 |
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
// Create a persistent container with an specific description for the stores | |
private(set) lazy var container: NSPersistentContainer = { | |
let description = NSPersistentStoreDescription() | |
description.type = NSSQLiteStoreType | |
description.shouldInferMappingModelAutomatically = false | |
description.shouldMigrateStoreAutomatically = true | |
let container = NSPersistentContainer(name: CoreDataStackTheNewWay.modelName) | |
container.persistentStoreDescriptions = [description] |
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 | |
// Extension on PropertyListSerialization to read an array from a property list file | |
extension PropertyListSerialization { | |
// Takes the name of the PLIST file to be read. Name must be provided without extension. | |
// returns an optional array if the file can be opened and parsed properly. | |
// - Parameters: | |
// - named String with the filename. No extension .plist needed | |
static func arrayFromPlist(named name: String) -> [Any]? { |
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
// Model used -> https://free3d.com/download-page.php?url=rose-31675 | |
let scene = SCNScene(named: "rose.obj") | |
// Set up the SceneView | |
sceneView.autoenablesDefaultLighting = true | |
sceneView.allowsCameraControl = true | |
sceneView.scene = scene | |
sceneView.backgroundColor = .black |
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
let effectView = UIVisualEffectView() | |
effectView.frame = view.bounds | |
effectView.autoresizingMask = [.flexibleWidth, .flexibleHeight] | |
view.addSubview(effectView) | |
let e = UIBlurEffect(style: .dark) | |
effectView.effect = e |
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
// iOS 10 working way to fade in a blurred view (changing alpha in the container does not work on iOS 10) | |
let effectView = UIVisualEffectView() | |
effectView.frame = toast.bounds | |
effectView.autoresizingMask = [.flexibleWidth, .flexibleHeight] | |
view.addSubview(effectView) //replace view with whatever view you want to blur | |
UIView.animate(withDuration: 0.2) { | |
let blur = UIBlurEffect(style: .light) | |
effectView.effect = blur |
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
// | |
// NotificationViewController.swift | |
// Content | |
// | |
// Created by Barbara Rodeker on 28/09/16. | |
// Copyright © 2016 Barbara Rodeker. All rights reserved. | |
// | |
import UIKit | |
import UserNotifications |
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
// | |
// NotificationService.swift | |
// Service | |
// | |
// Created by Barbara Rodeker on 28/09/16. | |
// Copyright © 2016 Barbara Rodeker. All rights reserved. | |
// | |
import UserNotifications |
NewerOlder