Last active
November 23, 2019 03:51
-
-
Save acwright/d4384f9e7f516adc7d034c0796ac34f5 to your computer and use it in GitHub Desktop.
@FetchRequest
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
struct StudentsView: View { | |
@FetchRequest( | |
entity: Student.entity(), | |
sortDescriptors: [], | |
predicate: NSPredicate(format: "name = %@", "Joe") | |
) var students: FetchedResults<Student> | |
var body: some View { | |
List { | |
ForEach(students) { student in | |
Text(student.name ?? "No Name") | |
} | |
Button(action: { | |
// How do I search for students with the first name Mary? | |
}) { | |
Text("Find Mary") | |
} | |
} | |
} | |
} | |
struct StudentsView_Previews: PreviewProvider { | |
static var previews: some View { | |
StudentsView() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment