Reprinted from http://blog.csdn.net/longhai0long/article/details/38379247
Just looking at Swift developing iOS, there was a problem with the core data framework, and the console typed the log as follows:
class ' collectnews ' for ' collectnews '. using default Nsmanagedobject instead.
Baffled, and later found a solution on the StackOverflow, is in the Model class switch plus this note:
Demo part of the code to share to everyone, only to do the reference:
Model class
Import Foundation Import CoreData
@objc (collectnews) class collectnews:nsmanagedobject { @NSManaged var date:nsnumber @NSManaged var newsid:nsnumber
Appdelegate class:
Func application (application:uiapplication!, Didfinishlaunchingwithoptions launchoptions:nsdictionary!)Bool {insertdata () Selectdata ()return true } //Inserting Datafunc InsertData () {//take entity Objectvar collectnews = Nsentitydescription.insertnewobjectforentityforname ("collectnews", InManagedObjectContext:self.managedObjectContext) ascollectnews//to modify a propertyCollectnews.newsid = Acollectnews.date=20140805 //Save ifself.managedobjectcontext.haschanges{Self.managedObjectContext.save (Nil)}}//Enquiryfunc selectdata () {//The request object.var request =nsfetchrequest () var entityqueue= Nsentitydescription.entityforname ("collectnews", InManagedObjectContext:self.managedObjectContext) request.entity=entityqueue var errorinfo:nserror?//Fetch result setvar Resultarr = self.managedObjectContext.executeFetchRequest (Request, error: &errorinfo) asNsarray println ("----"\ (resultarr.count)") var temp= resultarr[0] ascollectnews println ("--->\ (temp.newsid)") }
Swift ERROR-A class not found solution appears for swift development CoreData