{"id":4167,"date":"2025-05-08T08:50:00","date_gmt":"2025-05-07T23:50:00","guid":{"rendered":"https:\/\/www.elehobby.fun\/?page_id=4167"},"modified":"2025-05-08T08:50:00","modified_gmt":"2025-05-07T23:50:00","slug":"getting-started-with-swiftdata-for-swiftui-development","status":"publish","type":"page","link":"https:\/\/www.elehobby.fun\/?page_id=4167","title":{"rendered":"Getting Started with SwiftData for SwiftUI Development"},"content":{"rendered":"\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.appcoda.com\/content\/images\/size\/w30\/wordpress\/2023\/08\/bqx-sbn9bh8.jpg\" alt=\"Getting Started with SwiftData for SwiftUI Development\"\/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.appcoda.com\/content\/images\/2024\/05\/appcoda-swift-book-ad_300x250.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>Table of Contents<\/p>\n\n\n\n<p>One common question in SwiftUI app development is how to work with Core Data to save data permanently in the built-in database. Despite Apple\u2019s ongoing efforts to simplify the APIs of Core Data, new comers often find the framework challenging to use. However, there is good news on the horizon. Apple will be releasing a new framework called&nbsp;<a href=\"https:\/\/developer.apple.com\/xcode\/swiftdata\/?ref=appcoda.com\">SwiftData<\/a>&nbsp;in iOS 17 to replace Core Data. SwiftData is designed to be much easier to use for data modelling and management, offering a more user-friendly approach.<\/p>\n\n\n\n<div id=\"toc_container\" class=\"toc_light_blue no_bullets\"><p class=\"toc_title\">Contents<\/p><ul class=\"toc_list\"><li><a href=\"#Whats_SwiftData\"><span class=\"toc_number toc_depth_1\">1<\/span> What\u2019s SwiftData<\/a><\/li><li><a href=\"#Using_Code_to_Create_the_Data_Model\"><span class=\"toc_number toc_depth_1\">2<\/span> Using Code to Create the Data Model<\/a><\/li><li><a href=\"#Building_a_Simple_To_Do_App\"><span class=\"toc_number toc_depth_1\">3<\/span> Building a Simple To Do App<\/a><ul><li><a href=\"#Set_up_the_model_container\"><span class=\"toc_number toc_depth_2\">3.1<\/span> Set up the model container<\/a><\/li><li><a href=\"#Storing_to-do_items_into_the_database\"><span class=\"toc_number toc_depth_2\">3.2<\/span> Storing to-do items into the database<\/a><\/li><li><a href=\"#Updating_an_existing_item\"><span class=\"toc_number toc_depth_2\">3.3<\/span> Updating an existing item<\/a><\/li><li><a href=\"#Deleting_the_item_from_the_database\"><span class=\"toc_number toc_depth_2\">3.4<\/span> Deleting the item from the database<\/a><\/li><\/ul><\/li><li><a href=\"#Summary\"><span class=\"toc_number toc_depth_1\">4<\/span> Summary<\/a><\/li><\/ul><\/div>\n<h2 class=\"wp-block-heading\"><span id=\"Whats_SwiftData\">What\u2019s SwiftData<\/span><\/h2>\n\n\n\n<p>First and foremost, it\u2019s important to note that the SwiftData framework should not be confused with a database. Built on top of Core Data, SwiftData is actually a framework designed to help developers manage and interact with data on a persistent store. While the default persistent store for iOS is typically the SQLite database, it\u2019s worth noting that persistent stores can take other forms as well. For example, Core Data can also be used to manage data in a local file, such as an XML file.<\/p>\n\n\n\n<p>Regardless of whether you\u2019re using Core Data or the SwiftData framework, both tools serve to shield developers from the complexities of the underlying persistent store. Consider the SQLite database, for instance. With SwiftData, there\u2019s no need to worry about connecting to the database or understanding SQL in order to retrieve data records. Instead, developers can focus on working with APIs and Swift Macros, such as&nbsp;<code>@Query<\/code>&nbsp;and&nbsp;<code>@Model<\/code>, to effectively manage data in their applications.<\/p>\n\n\n\n<p>The SwiftData framework is newly introduced in iOS 17 to replace the previous framework called Core Data. Core Data has long been the data management APIs for iOS development since the era of Objective-C. Even though developers can integrate the framework into Swift projects, Core Data is not a native solution for both Swift and&nbsp;<a href=\"https:\/\/www.appcoda.com\/swiftui\">SwiftUI<\/a>.<\/p>\n\n\n\n<p>In iOS 17, Apple finally introduces a native framework called SwiftData for Swift on persistent data management and data modeling. It\u2019s built on top of Core Data but the APIs are completely redesigned to make the most out of Swift.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span id=\"Using_Code_to_Create_the_Data_Model\">Using Code to Create the Data Model<\/span><\/h2>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.appcoda.com\/content\/images\/wordpress\/2023\/08\/todoappdemo-coredata.png\" alt=\"swiftui-coredata-model-editor\" class=\"wp-image-21168\"\/><\/figure>\n\n\n\n<p>If you have used Core Data before, you may remember that you have to create a data model (with a file extension .xcdatamodeld) using a data model editor for data persistence. With the release of SwiftData, you no longer need to do that. SwiftData streamlines the whole process with macros, another new Swift feature in iOS 17. Say, for example, you already define a model class for Song as follows:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class Song {\n  var title: String\n  var artist: String\n  var album: String\n  var genre: String\n  var rating: Double\n}<\/pre>\n\n\n\n<p>To use SwiftData, the new&nbsp;<code>@Model<\/code>&nbsp;macro is the key for storing persistent data using SwiftUI. Instead of building the data model with model editor, SwiftData just requires you to annotate the model class with the&nbsp;<code>@Model<\/code>&nbsp;macro like this:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">@Model class Song {\n  var title: String\n  var artist: String\n  var album: String\n  var genre: String\n  var rating: Double\n}<\/pre>\n\n\n\n<p>This is how you define the schema of the data model in code. With this simple keyword, SwiftData automatically enables persistence for the data class and offers other data management functionalities such as iCloud sync. Attributes are inferred from properties and it supports basic value types such as Int and String.<\/p>\n\n\n\n<p>SwiftData allows you to customize how your schema is built using property metadata. You can add uniqueness constraints by using the&nbsp;<code>@Attribute<\/code>&nbsp;annotation, and delete propagation rules with the&nbsp;<code>@Relationship<\/code>&nbsp;annotation. If there are certain properties you do not want included, you can use the&nbsp;<code>@Transient<\/code>&nbsp;macro to tell SwiftData to exclude them. Here is an example:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">@Model class Album {\n  @Attribute(.unique) var name: String\n  var artist: String\n  var genre: String\n\n  \/\/ The cascade relationship instructs SwiftData to delete all \n    \/\/ songs when the album is deleted.\n  @Attribute(.cascade) var songs: [Song]? = []\n}<\/pre>\n\n\n\n<p>To drive the data persistent operations, there are two key objects of SwiftData that you should be familiar with:&nbsp;<code>ModelContainer<\/code>&nbsp;and&nbsp;<code>ModelContext<\/code>. The&nbsp;<code>ModelContainer<\/code>&nbsp;serves as the persistent backend for your model types. To create a&nbsp;<code>ModelContainer<\/code>, you simply need to instantiate an instance of it.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ Basic\nlet container = try ModelContainer(for: [Song.self, Album.self])\n\n\/\/ With configuration\nlet container = try ModelContainer(for: [Song.self, Album.self], \n                                    configurations: ModelConfiguration(url: URL(\"path\"))))<\/pre>\n\n\n\n<p>In SwiftUI, you can set up the model container at the root of the application:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import SwiftData\nimport SwiftUI\n\n@main\nstruct MusicApp: App {\n    var body: some Scene {\n        WindowGroup {\n            ContentView()\n        }\n        .modelContainer (for: [Song.self, Album.self]))\n    }\n}<\/pre>\n\n\n\n<p>Once you have set up the model container, you can begin using the model context to fetch and save data. The context serves as your interface for tracking updates, fetching data, saving changes, and even undoing those changes. When working with SwiftUI, you can typically obtain the model context from your view\u2019s environment:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">struct ContextView: View {\n    @Environment(\\.modelContext) private var modelContext\n}<\/pre>\n\n\n\n<p>With the context, you are ready to fetch data. The simplest way is to use the&nbsp;<code>@Query<\/code>&nbsp;property wrapper. You can easily load and filter anything stored in your database with a single line of code.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">@Query(sort: \\.artist, order: .reverse) var songs: [Song]<\/pre>\n\n\n\n<p>To insert item in the persistent store, you can call the insert method of the model context and pass it the model objects to insert.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">modelContext.insert(song)<\/pre>\n\n\n\n<p>Similarly, you can delete the item via the model context like this:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">modelContext.delete(song)<\/pre>\n\n\n\n<p>This is a brief introduction of SwiftData. If you\u2019re still feeling confused about how to use SwiftData? No worries. You will understand its usage after building a ToDO app.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span id=\"Building_a_Simple_To_Do_App\">Building a Simple To Do App<\/span><\/h2>\n\n\n\n<p>Now that you have a basic understanding of SwiftData, I would like to demonstrate how to build a simple to-do app using this framework. Please note that the app is not fully functional and only allows users to add a random task to the to-do list. However, it serves as a good starting point to familiarize yourself with the SwiftData framework.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.appcoda.com\/content\/images\/wordpress\/2023\/08\/todoappdemo.gif\" alt=\"swiftui-swiftdata-todo-app\" class=\"wp-image-21169\"\/><\/figure>\n\n\n\n<p>Assuming you\u2019ve created a SwiftUI project in Xcode, let\u2019s first create the data model of the app. Create a new file named&nbsp;<code>ToDoItem<\/code>&nbsp;and update the content like this:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import Foundation\nimport SwiftData\n\n@Model class ToDoItem: Identifiable {\n    var id: UUID\n    var name: String\n    var isComplete: Bool\n\n    init(id: UUID = UUID(), name: String = \"\", isComplete: Bool = false) {\n        self.id = id\n        self.name = name\n        self.isComplete = isComplete\n    }\n}<\/pre>\n\n\n\n<p>As discussed earlier, SwiftData simplifies the process of defining a schema using code. All you need to do is annotate the model class with the&nbsp;<code>@Model<\/code>&nbsp;macro. SwiftData will then automatically enable persistence for the data class.<\/p>\n\n\n\n<p>Before we move onto building the UI of the app and handling the data persistent, let\u2019s create a helper function for generating a random to-do item:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">func generateRandomTodoItem() -> ToDoItem {\n    let tasks = [ \"Buy groceries\", \"Finish homework\", \"Go for a run\", \"Practice Yoga\", \"Read a book\", \"Write a blog post\", \"Clean the house\", \"Walk the dog\", \"Attend a meeting\" ]\n\n    let randomIndex = Int.random(in: 0..&lt;tasks.count)\n    let randomTask = tasks[randomIndex]\n\n    return ToDoItem(name: randomTask, isComplete: Bool.random())\n}<\/pre>\n\n\n\n<p>Next, let\u2019s build the main UI of the to-do app. In the&nbsp;<code>ContentView.swift<\/code>&nbsp;file, update the code like this:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import SwiftData\n\nstruct ContentView: View {\n    @Query var todoItems: [ToDoItem]\n\n    var body: some View {\n        NavigationStack {\n            List {\n                ForEach(todoItems) { todoItem in\n                    HStack {\n                        Text(todoItem.name)\n\n                        Spacer()\n\n                        if todoItem.isComplete {\n                            Image(systemName: \"checkmark\")\n                        }\n                    }\n                }\n            }\n\n            .navigationTitle(\"To Do List\")\n        }\n    }\n}<\/pre>\n\n\n\n<p>We mark the&nbsp;<code>todoItems<\/code>&nbsp;array with the&nbsp;<code>@Query<\/code>&nbsp;property wrapper. This&nbsp;<code>@Query<\/code>&nbsp;property automatically fetches the required data for you. In the provided code, we specify to fetch the&nbsp;<code>ToDoItem<\/code>&nbsp;instances. Once we retrieve the to-do items, we utilize the&nbsp;<code>List<\/code>&nbsp;view to display the items.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span id=\"Set_up_the_model_container\">Set up the model container<\/span><\/h3>\n\n\n\n<p>To drive the data persistent operations, we also need to set up the model container. Switch over to&nbsp;<code>ToDoDemoAppApp.swift<\/code>&nbsp;and attach the&nbsp;<code>modelContainer<\/code>&nbsp;modifier like this:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">struct ToDoDemoAppApp: App {\n    var body: some Scene {\n        WindowGroup {\n            ContentView()\n        }\n        .modelContainer(for: ToDoItem.self)\n    }\n}<\/pre>\n\n\n\n<p>Here, we set a shared model container for storing instances of&nbsp;<code>ToDoItem<\/code>.<\/p>\n\n\n\n<p>If you preview the&nbsp;<code>ContentView<\/code>, the list view is empty. Obviously, we haven\u2019t stored any to-do items in the database. Now, let\u2019s add a \u201cAdd item\u201d button to insert a random to-do item into the database.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span id=\"Storing_to-do_items_into_the_database\">Storing to-do items into the database<\/span><\/h3>\n\n\n\n<p>In&nbsp;<code>ContentView.swift<\/code>, declare the following variable to retrieve the model context:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">@Environment(\\.modelContext) private var modelContext<\/pre>\n\n\n\n<p>After obtaining the model context, we can easily insert data into the database. We\u2019ll add a toolbar button for adding a random to-do item. Insert the following code inside the&nbsp;<code>NavigationStack<\/code>&nbsp;view (place it after&nbsp;<code>navigationTitle<\/code>):<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">.toolbar {\n    Button(\"\", systemImage: \"plus\") {\n        modelContext.insert(generateRandomTodoItem())\n    }\n}<\/pre>\n\n\n\n<p>To store an item into database, you simply call the&nbsp;<code>insert<\/code>&nbsp;method of the model context.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.appcoda.com\/content\/images\/wordpress\/2023\/08\/todoappdemo-preview.png\" alt=\"swiftui-todo-list-model-context\" class=\"wp-image-21170\"\/><\/figure>\n\n\n\n<p>Now you\u2019re ready to test the app in the simulator. However, if you intend to test it in the preview canvas, you need to make one additional modification by adding the model container within the&nbsp;<code>#Preview<\/code>&nbsp;block:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#Preview {\n    ContentView()\n        .modelContainer(for: ToDoItem.self)\n}<\/pre>\n\n\n\n<p>When you tap the \u201c+\u201d button, the app instantly stores the to-do item. Simultaneously, it retrieves the new item from the database and displays it in the list view.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span id=\"Updating_an_existing_item\"><strong>Updating an existing item<\/strong><\/span><\/h3>\n\n\n\n<p>SwiftData significantly reduces the amount of work required to handle item updates or modifications in the persistent store. By simply marking your model objects with the&nbsp;<code>@Model<\/code>&nbsp;macro, SwiftData automatically modifies the setters for change tracking and observation. This means that no code changes are needed to update the to-do items.<\/p>\n\n\n\n<p>To test the update behavior, you can simply run the app on a simulator. When you tap a to-do item, it should be marked as complete. This change is now saved permanently in the device\u2019s database. Even after restarting the app, all the items will still be retained.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span id=\"Deleting_the_item_from_the_database\">Deleting the item from the database<\/span><\/h3>\n\n\n\n<p>Now that you know how to perform fetch, update, and insert, how about data deletion? We will add a feature to the app for removing a to-do item.<\/p>\n\n\n\n<p>In the&nbsp;<code>ContentView<\/code>&nbsp;struct, attach the&nbsp;<code>onDelete<\/code>&nbsp;modifier to the&nbsp;<code>ForEach<\/code>&nbsp;loop:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">.onDelete(perform: { indexSet in\n    for index in indexSet {\n        let itemToDelete = todoItems[index]\n        modelContext.delete(itemToDelete)\n    }\n})<\/pre>\n\n\n\n<p>This closure takes an index set that stores the indices of the items to be deleted. To remove an item from the persistent store, simply call the&nbsp;<code>delete<\/code>&nbsp;function of the model context and specify the item to be deleted.<\/p>\n\n\n\n<p>The&nbsp;<code>onDelete<\/code>&nbsp;modifier automatically enables the swipe-to-delete feature in the list view. To try this out, simply run the app and swipe to delete an item. This will completely remove the item from the database.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span id=\"Summary\">Summary<\/span><\/h2>\n\n\n\n<p>I hope that you now have a better understanding of how to integrate SwiftData into a SwiftUI project and how to perform all basic CRUD (create, read, update &amp; delete) operations. Apple has put a lot of efforts to make persistent data management and data modeling easier for Swift developers and new comers.<\/p>\n\n\n\n<p>While Core Data remains an option for backward compatibility, it\u2019s time to learn the SwiftData framework, especially if you are developing an app exclusively for iOS 17 or later. Embrace this new framework to leverage the enhanced capabilities and benefits SwiftData offers.<\/p>\n<div class=\"veu_socialSet veu_socialSet-position-after veu_contentAddSection\"><script>window.twttr=(function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],t=window.twttr||{};if(d.getElementById(id))return t;js=d.createElement(s);js.id=id;js.src=\"https:\/\/platform.twitter.com\/widgets.js\";fjs.parentNode.insertBefore(js,fjs);t._e=[];t.ready=function(f){t._e.push(f);};return t;}(document,\"script\",\"twitter-wjs\"));<\/script><ul><li class=\"sb_facebook sb_icon\"><a class=\"sb_icon_inner\" href=\"\/\/www.facebook.com\/sharer.php?src=bm&u=https%3A%2F%2Fwww.elehobby.fun%2F%3Fpage_id%3D4167&amp;t=%E5%AE%9F%E8%B7%B5%E3%81%A7%E3%81%8D%E3%81%9F%E9%9B%BB%E5%AD%90%E5%B7%A5%E4%BD%9C%E3%81%A8%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%9F%E3%83%B3%E3%82%B0%E9%96%8B%E7%99%BA\" target=\"_blank\" onclick=\"window.open(this.href,'FBwindow','width=650,height=450,menubar=no,toolbar=no,scrollbars=yes');return false;\"><span class=\"vk_icon_w_r_sns_fb icon_sns\"><\/span><span class=\"sns_txt\">Facebook<\/span><span class=\"veu_count_sns_fb\"><\/span><\/a><\/li><li class=\"sb_twitter sb_icon\"><a class=\"sb_icon_inner\" href=\"\/\/twitter.com\/intent\/tweet?url=https%3A%2F%2Fwww.elehobby.fun%2F%3Fpage_id%3D4167&amp;text=%E5%AE%9F%E8%B7%B5%E3%81%A7%E3%81%8D%E3%81%9F%E9%9B%BB%E5%AD%90%E5%B7%A5%E4%BD%9C%E3%81%A8%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%9F%E3%83%B3%E3%82%B0%E9%96%8B%E7%99%BA\" target=\"_blank\" ><span class=\"vk_icon_w_r_sns_twitter icon_sns\"><\/span><span class=\"sns_txt\">twitter<\/span><\/a><\/li><li class=\"sb_hatena sb_icon\"><a class=\"sb_icon_inner\" href=\"\/\/b.hatena.ne.jp\/add?mode=confirm&url=https%3A%2F%2Fwww.elehobby.fun%2F%3Fpage_id%3D4167&amp;title=%E5%AE%9F%E8%B7%B5%E3%81%A7%E3%81%8D%E3%81%9F%E9%9B%BB%E5%AD%90%E5%B7%A5%E4%BD%9C%E3%81%A8%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%9F%E3%83%B3%E3%82%B0%E9%96%8B%E7%99%BA\" target=\"_blank\"  onclick=\"window.open(this.href,'Hatenawindow','width=650,height=450,menubar=no,toolbar=no,scrollbars=yes');return false;\"><span class=\"vk_icon_w_r_sns_hatena icon_sns\"><\/span><span class=\"sns_txt\">Hatena<\/span><span class=\"veu_count_sns_hb\"><\/span><\/a><\/li><li class=\"sb_pocket sb_icon\"><a class=\"sb_icon_inner\"  href=\"\/\/getpocket.com\/edit?url=https%3A%2F%2Fwww.elehobby.fun%2F%3Fpage_id%3D4167&title=%E5%AE%9F%E8%B7%B5%E3%81%A7%E3%81%8D%E3%81%9F%E9%9B%BB%E5%AD%90%E5%B7%A5%E4%BD%9C%E3%81%A8%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%9F%E3%83%B3%E3%82%B0%E9%96%8B%E7%99%BA\" target=\"_blank\"  onclick=\"window.open(this.href,'Pokcetwindow','width=650,height=450,menubar=no,toolbar=no,scrollbars=yes');return false;\"><span class=\"vk_icon_w_r_sns_pocket icon_sns\"><\/span><span class=\"sns_txt\">Pocket<\/span><span class=\"veu_count_sns_pocket\"><\/span><\/a><\/li><li class=\"sb_copy sb_icon\"><button class=\"copy-button sb_icon_inner\"data-clipboard-text=\"\u5b9f\u8df5\u3067\u304d\u305f\u96fb\u5b50\u5de5\u4f5c\u3068\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u958b\u767a https:\/\/www.elehobby.fun\/?page_id=4167\"><span class=\"vk_icon_w_r_sns_copy icon_sns\"><i class=\"fas fa-copy\"><\/i><\/span><span class=\"sns_txt\">Copy<\/span><\/button><\/li><\/ul><\/div><!-- [ \/.socialSet ] -->","protected":false},"excerpt":{"rendered":"<p>Table of Contents One common question in SwiftUI app development is how to work with Core Data to save data pe [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"vkexunit_cta_each_option":"","footnotes":""},"class_list":["post-4167","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.elehobby.fun\/index.php?rest_route=\/wp\/v2\/pages\/4167","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.elehobby.fun\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.elehobby.fun\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.elehobby.fun\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.elehobby.fun\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4167"}],"version-history":[{"count":1,"href":"https:\/\/www.elehobby.fun\/index.php?rest_route=\/wp\/v2\/pages\/4167\/revisions"}],"predecessor-version":[{"id":4168,"href":"https:\/\/www.elehobby.fun\/index.php?rest_route=\/wp\/v2\/pages\/4167\/revisions\/4168"}],"wp:attachment":[{"href":"https:\/\/www.elehobby.fun\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4167"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}