{"id":49,"date":"2023-11-10T13:55:11","date_gmt":"2023-11-10T06:55:11","guid":{"rendered":"https:\/\/sekjell.com\/swift\/?page_id=49"},"modified":"2023-11-10T14:11:55","modified_gmt":"2023-11-10T07:11:55","slug":"swift-swiftui-blogs","status":"publish","type":"page","link":"https:\/\/sekjell.com\/swift\/swift-swiftui-blogs\/","title":{"rendered":"Snippets"},"content":{"rendered":"\n<div class=\"wp-block-query is-layout-flow wp-block-query-is-layout-flow\">\n<div class=\"wp-block-group is-layout-constrained wp-block-group-is-layout-constrained\">\n<div class=\"wp-block-query is-layout-flow wp-block-query-is-layout-flow\"><ul class=\"has-link-color wp-elements-ba730721a11a8636767de449cd3aa596 wp-block-post-template has-text-color has-black-color has-background has-palette-color-6-background-color is-layout-flow wp-block-post-template-is-layout-flow\"><li class=\"wp-block-post post-73 post type-post status-publish format-standard hentry category-uncategorized\">\n<h2 class=\"wp-block-post-title wp-elements-ba730721a11a8636767de449cd3aa596\"><a href=\"https:\/\/sekjell.com\/swift\/2023\/11\/19\/make-swiftdata-codable\/\" target=\"_self\" >Make SwiftData Codable<\/a><\/h2>\n\n\n\n<div class=\"wp-block-post-excerpt\"><p class=\"wp-block-post-excerpt__excerpt\">When moving from Core Data to Swift Data, it&#8217;s not obvious how to make the data model codable, a must for reading or writing JSON files or API&#8217;s to\/from the persistent storage. A way to do it is to manually add Codekeys so that the @Model knows that the data types are supported. Here is<\/p><p class=\"wp-block-post-excerpt__more-text\"><a class=\"wp-block-post-excerpt__more-link\" href=\"https:\/\/sekjell.com\/swift\/2023\/11\/19\/make-swiftdata-codable\/\">Read more &#8230;.<\/a><\/p><\/div>\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n<div class=\"wp-block-post-date\"><time datetime=\"2023-11-19T19:53:13+07:00\"><a href=\"https:\/\/sekjell.com\/swift\/2023\/11\/19\/make-swiftdata-codable\/\">November 19, 2023<\/a><\/time><\/div>\n<\/li><li class=\"wp-block-post post-43 post type-post status-publish format-standard hentry category-swiftui\">\n<h2 class=\"wp-block-post-title wp-elements-ba730721a11a8636767de449cd3aa596\"><a href=\"https:\/\/sekjell.com\/swift\/2023\/11\/10\/show-the-device\/\" target=\"_self\" >Show the device<\/a><\/h2>\n\n\n\n<div class=\"wp-block-post-excerpt\"><p class=\"wp-block-post-excerpt__excerpt\">To show what kind of device the user have, you can add this code to a swift file In the view you can now add The deviceType.iDevice will show &#8220;iPhone&#8221;, &#8220;iPad&#8221; or &#8220;iPod&#8221; etc. as String<\/p><p class=\"wp-block-post-excerpt__more-text\"><a class=\"wp-block-post-excerpt__more-link\" href=\"https:\/\/sekjell.com\/swift\/2023\/11\/10\/show-the-device\/\">Read more &#8230;.<\/a><\/p><\/div>\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n<div class=\"wp-block-post-date\"><time datetime=\"2023-11-10T13:44:29+07:00\"><a href=\"https:\/\/sekjell.com\/swift\/2023\/11\/10\/show-the-device\/\">November 10, 2023<\/a><\/time><\/div>\n<\/li><\/ul><\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-49","page","type-page","status-publish","hentry"],"blocksy_meta":"","_links":{"self":[{"href":"https:\/\/sekjell.com\/swift\/wp-json\/wp\/v2\/pages\/49","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sekjell.com\/swift\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/sekjell.com\/swift\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/sekjell.com\/swift\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sekjell.com\/swift\/wp-json\/wp\/v2\/comments?post=49"}],"version-history":[{"count":9,"href":"https:\/\/sekjell.com\/swift\/wp-json\/wp\/v2\/pages\/49\/revisions"}],"predecessor-version":[{"id":63,"href":"https:\/\/sekjell.com\/swift\/wp-json\/wp\/v2\/pages\/49\/revisions\/63"}],"wp:attachment":[{"href":"https:\/\/sekjell.com\/swift\/wp-json\/wp\/v2\/media?parent=49"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}