TAG: ios

Software and more


CoreData CRUD methods in Swift 2.0

With Swift 2.0, Apple introduced a protocol oriented way of programming. I want to use this to create a protocol that adds CRUD functionality to CoreData models without the need for all the type casting. import Foundation import CoreData protocol CoreDataCRUD { } extension CoreDataCRUD where Self : NSManagedObject { static func create() -> Self { return NSEntityDescription.insertNewObjectForEntityForName(Utility.classNameAsString(self), inManagedObjectContext: sharedCoreDataManager.context()) as! Self } static func findById(id: String) throws -> Self? { let fetchRequest = NSFetchRequest(…

Swift CoreData: generate swift NSManagedObjects

This is a follow up to my previous post about Xcode6 and CoreData. If you set the class in your xcdatamodel to <MyAppName>.User and create the NSManagedObjects from the entities, Xcode6 does not generate the correct .swift model files. It parses the class <MyAppName>.User only to the . and creates a single <MyAppName>.swift file. For now the only fix i have is to rename the class to User,…