Stanford CS193p: iOS Development with SwiftUI | 2025 | L13: SwiftData
View course details: https://online.stanford.edu/courses/cs193p-ios-application-development
All course materials are available at https://cs193p.stanford.edu.
The 13th lecture of the 2025 version of Stanford's CS193p course (developing applications for iOS using SwiftUI). Using SwiftData to make an app's data persistent. Shows how to convert a Model from structs to @Model classes. Explains the restrictions on @Model var types (primitives, other @Models, Codables, Arrays), using @Relationship annotations for table relationships, and using @Transient for non-persistent data. Key concepts include ModelContainer setup in the app and #Preview, using @Environment(\.modelContext) to access the database, and creating FetchDescriptors with #Predicates and sorting. Covers error handling with try/catch, computed properties for type conversion between Model and UI representations, and the constraints of database queries (no computed vars in predicates).
Paul Hegarty is a Lecturer who has been teaching CS193p at Stanford since 2010.
Stanford Online
You can gain access to a world of education through Stanford Online, the Stanford School of Engineering’s portal for academic and professional education offered by schools and units throughout Stanford University. https://online.stanford.edu/ Our robust ...