بنقرة واحدة
swift-data
SwiftData persistence framework with models, queries, relationships, and CloudKit sync
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
SwiftData persistence framework with models, queries, relationships, and CloudKit sync
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Comprehensive iOS development guidance covering SwiftUI, Swift Concurrency, Core Data, and Swift Testing
SQLiteData persistence library (Point-Free) - a fast SwiftData alternative using SQLite/GRDB. Use when working with SQLiteData, GRDB, type-safe SQL queries, @Table macro, @FetchAll/@FetchOne property wrappers, or migrating from SwiftData to SQLite-based persistence.
Technical blog writing with engaging hooks, progressive complexity, and code-first explanations
Comprehensive code review for quality, security, performance, and best practices across any language
Designs comprehensive implementation plans for new features with architecture considerations
Creates distinctive, production-grade frontend interfaces with high design quality, avoiding generic AI aesthetics
| name | swift_data |
| description | SwiftData persistence framework with models, queries, relationships, and CloudKit sync |
You are a SwiftData expert. Apply these patterns when working with data persistence in Swift apps.
| Need | Reference |
|---|---|
| Define models and properties | → model-basics.md |
| Create relationships between models | → relationships.md |
| Query, filter, and sort data | → queries-filtering.md |
| Configure containers and contexts | → containers-contexts.md |
| Enable iCloud sync | → cloudkit-sync.md |
| Handle schema migrations | → migration.md |
| Optimize performance | → performance.md |
| Debug and troubleshoot | → common-issues.md |
import SwiftData
@Model
final class Book {
var title: String
var author: String
var publishedDate: Date
var rating: Int?
init(title: String, author: String, publishedDate: Date) {
self.title = title
self.author = author
self.publishedDate = publishedDate
}
}
@main
struct MyApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
.modelContainer(for: Book.self)
}
}
struct BookList: View {
@Query(sort: \Book.title) var books: [Book]
@Environment(\.modelContext) var modelContext
var body: some View {
List(books) { book in
Text(book.title)
}
}
}
// Create
let book = Book(title: "Swift Guide", author: "Apple", publishedDate: .now)
modelContext.insert(book)
// Read - use @Query or fetch
let descriptor = FetchDescriptor<Book>(
predicate: #Predicate { $0.rating ?? 0 > 3 },
sortBy: [SortDescriptor(\.title)]
)
let books = try modelContext.fetch(descriptor)
// Update - modify properties directly
book.title = "Updated Title"
// Delete
modelContext.delete(book)
For comprehensive SwiftData tutorials, check Hacking with Swift - SwiftData.