Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 从核心数据实体获取NSSet_Ios_Swift_Nsmanagedobject_Core_Nsset - Fatal编程技术网

Ios 从核心数据实体获取NSSet

Ios 从核心数据实体获取NSSet,ios,swift,nsmanagedobject,core,nsset,Ios,Swift,Nsmanagedobject,Core,Nsset,我有一个NSManagedObject类(SearchHistory.swift),它与(Hospital.swift)类有关系 我试图获取NSSet,但它给了我编译错误:使用了未声明的类型“SearchHistory”,尽管我以相同的方式获取其他实体,并且没有任何错误 let AppDel: AppDelegate = UIApplication.sharedApplication().delegate as! AppDelegate let Context: NSMa

我有一个NSManagedObject类(SearchHistory.swift),它与(Hospital.swift)类有关系

我试图获取NSSet,但它给了我编译错误:使用了未声明的类型“SearchHistory”,尽管我以相同的方式获取其他实体,并且没有任何错误

let AppDel: AppDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
            let Context: NSManagedObjectContext = AppDel.managedObjectContext!
            let request = NSFetchRequest(entityName: "SearchHistory")
            var search = Context.executeFetchRequest(request, error: nil) as! [SearchHistory] // ERROR HERE :(
            for (var x=0; x<search.count; x++) {
                let hospitalsArray: NSArray = search[x].hospitals.allObjects

                for hospital in hospitalsArray {
                    println(hospital.hospital_name)
                }
            }
让AppDel:AppDelegate=UIApplication.sharedApplication().delegate为!AppDelegate
让上下文:NSManagedObjectContext=AppDel.managedObjectContext!
let request=NSFetchRequest(entityName:“SearchHistory”)
var search=Context.executeFetchRequest(请求,错误:nil)为![SearchHistory]//此处出错:(

对于(var x=0;xIf),如果这是真正的错误消息,您在“SearchHistroty”上的某个地方有一个拼写错误。@PhillipMills这是一个拼写错误
let AppDel: AppDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
            let Context: NSManagedObjectContext = AppDel.managedObjectContext!
            let request = NSFetchRequest(entityName: "SearchHistory")
            var search = Context.executeFetchRequest(request, error: nil) as! [SearchHistory] // ERROR HERE :(
            for (var x=0; x<search.count; x++) {
                let hospitalsArray: NSArray = search[x].hospitals.allObjects

                for hospital in hospitalsArray {
                    println(hospital.hospital_name)
                }
            }