let fetchRequest: NSFetchRequest<UserModel_CD> = UserModel_CD.fetchRequest()
//Query on which basic data will be found from coreData
fetchRequest.predicate = NSPredicate(format: "email == %@ && password == %@", email, password)
//This query in SQl looks like -
//SELECT * FROM Users WHERE email = 'user@example.com' AND password = 'password123';
do {
let fetchedData = try viewContext.fetch(fetchRequest)
return fetchedData.count > 0
} catch {
return false
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter