Jestem nowym użytkownikiem Swift i próbuję nauczyć się korzystać z Core Data. Ale dostaję tego błędu i nie jestem pewien, co zrobiłem źle. Szukałem w Internecie i wypróbowałem kilka rzeczy, ale nie mogę tego naprawić.Rozwiązywanie "Nie można wywołać określonego inicjalizatora w klasie NSManagedObject"
Failed to call designated initializer on NSManagedObject class 'FirstCoreData.Course'
Kiedy ta linia wykonuje:
ncvc.currentCourse = newCourse
W tej funkcji:
class TableViewController: UITableViewController, AddCourseViewControllerDelegate {
var managedObjectContext = NSManagedObjectContext.init(concurrencyType: NSManagedObjectContextConcurrencyType.MainQueueConcurrencyType)
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "addCourse" {
let ncvc = segue.destinationViewController as! NewCourseViewController
ncvc.delegate = self
let newCourse = NSEntityDescription.insertNewObjectForEntityForName("Course", inManagedObjectContext: self.managedObjectContext) as! Course
ncvc.currentCourse = newCourse
}
}
klasy generowane przez "Create NSManagedObject podklasy ..." dla podmiotu przedmiotu:
import Foundation
import CoreData
class Course: NSManagedObject {
// Insert code here to add functionality to your managed object subclass
}
I:
import Foundation
import CoreData
extension Course {
@NSManaged var title: String?
@NSManaged var author: String?
@NSManaged var releaseDate: NSDate?
}
Dzięki @pdasdf to działa dobrze dla mnie. – Chetan
Dobra rada! Wspaniały. –