1
我需要添加核心数据条件我该怎么做? 。如果记录是在这种情况下, “sonuc” 变量将是真正的核心数据条件
核心数据模型:
如果 “kullaniciadi” 是 “埃姆雷” 和 “otogiris” 为“1 “那么 ”sonuc“ 将 是真的
func getContext() -> NSManagedObjectContext {
let appDelegate = UIApplication.shared.delegate as! AppDelegate
if #available(iOS 10.0, *) {
return appDelegate.persistentContainer.viewContext
} else {
return DatabaseController.managedObjectContext
}
}
func otomatikGirisKontrol() -> Bool
{
var sonuc = false
let fetchRequest:NSFetchRequest<NSFetchRequestResult> = NSFetchRequest(entityName: "Kullanicilar")
fetchRequest.returnsObjectsAsFaults = false
do{
let results = try getContext().fetch(fetchRequest)
if results.count > 0
{
sonuc = true
}
else
{
sonuc = false
}
}
catch
{
}
return (sonuc)
}
谢谢“浅思”,它工作 –