xcode - Could not cast value of type - Objective C NSManagedObject in Swift -


i've found numerous posts error being able resolve adding prefix of project name class in entity viewer e.g projectname.journey suggestion of adding @objc(classname) above class declaration. these solutions don't work me. problem have nsmanagedobject class generated in objective c try access in swift. following error:

unable load class named 'projectname.journey' entity 'journey'.  class not found, using default nsmanagedobject instead. not cast value of type 'nsmanagedobject_journey_' (0x1700541f0) 'journey' (0x100096f38).  

my class: h:

#import <foundation/foundation.h> #import <coredata/coredata.h>   @interface journey : nsmanagedobject  @property (nonatomic, retain) nsstring * travelmode; @property (nonatomic, retain) nsdate * starttime; @property (nonatomic, retain) nsdate * endtime; @property (nonatomic, retain) nsnumber * averagespeed; @property (nonatomic, retain) nsnumber * distance;  @end 

m:

#import "journey.h"  @implementation journey  @dynamic travelmode; @dynamic starttime; @dynamic endtime; @dynamic averagespeed; @dynamic distance;  @end 

my code trying access code in swift:

for res in results {   var move: journey = res as! journey; //error thrown here   var morningstamp = midnightdate!.timeintervalsince1970;   var eveningstamp = morningstamp + 86400;   if(move.starttime.timeintervalsince1970 > morningstamp) {      if(move.endtime.timeintervalsince1970 < eveningstamp)     {       filtered.addobject(move);     }    } } 

bridge header file:

// //  use file import target's public headers expose swift. //  #import "travelrecordmanager.h" #import "journey.h" 


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -