This file contains 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
extension ModelContainer { | |
// non-throwing version | |
nonisolated func runNonisolated<ResultType, ActorType: InitWithModelContainer>( | |
action: @Sendable (_ actor: ActorType) async -> ResultType | |
) async -> ResultType { | |
let actor = ActorType(modelContainer: self) | |
let result = await action(actor) | |
return result | |
} | |
// throwing version |
This file contains 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
// Our one super simple SwiftData Model | |
@Model | |
class Item { | |
... | |
} | |
// MARK: - TodayView | |
@MainActor |
This file contains 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
// MARK: - TodayView | |
@MainActor | |
struct TodayView: View { | |
@State private var viewModel = TodayViewModel() | |
@Environment(\.modelContext) private var modelContext | |
var body: some View { | |
HStack { | |
switch viewModel.content { |
This file contains 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
struct ContentView: View { | |
var body: some View { | |
List { | |
SomeRow() | |
// set the background of the row | |
.listRowBackground(ListRowBackground()) | |
// .listRowSelectedBackground(ListRowSelectedBackground()) | |
// Oh no, `listRowSelectedBackground` above is not a real API, so list cells don't highlight when selected anymore. | |
// What do we do now? |
This file contains 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
// slow version | |
struct MyFancyList: View { | |
@Query(FetchDescriptors.fancyListItems) var items | |
var sections: [ListSection] = [] | |
var body: some View { | |
// it's a bad idea to build sections here, as that can execute for all sorts of updates to the view (there's more going on in this view in the original code) | |
SomethingRenderingSections(ListSection.sections(for: items, editMode: editMode, searchText: searchText) | |
.fullScreenCover(isPresented: $someFullScreenThingVisible) { SomethingThatCovers() } |
This file contains 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
-- _Ents: Filters current entities in the engine, matching their component names and/or display names. | |
-- | |
-- @param pattern: filter by entities with component names matching pattern. Empty string "" matches all. | |
-- @param displayNamePattern: filter by entities with displayName (where displayName is a heuristic determined | |
-- from various components) matching `displayNamePattern`. Empty string "" matches all. | |
-- @param withComponents: include component names in the output result | |
-- | |
_Ents = function(pattern, displayNamePattern, withComponents) | |
local entities = Ext.Entity.GetAllEntities() | |
local result = {} |
This file contains 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
using System; | |
namespace Entitas { | |
/** Used in the *AnyChangeObservable methods to observe multiple change types */ | |
[Flags] | |
public enum ChangeType : short{ | |
Addition = 1 << 0, | |
Replacement = 1 << 1, | |
Removal = 1 << 2, |
This file contains 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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE en-export SYSTEM "http://xml.evernote.com/pub/evernote-export2.dtd"> | |
<en-export export-date="20120322T185030Z" application="Evernote" version="Evernote Mac 3.0.6 (221382)"> | |
<note><title>1.0 meal</title><content><![CDATA[<?xml version='1.0' encoding='utf-8'?> | |
<!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd"> | |
<en-note style="margin:10px;background-color:rgb(86, 81, 78);font-size:13px;color:rgb(80, 80, 80);text-align:center;font-family:Helvetica;"> | |
<div style="font-size:13px;color:rgb(80, 80, 80);text-align:center;font-family:Helvetica;x-evernote:food-meal;"> | |
<div style="max-width:600px;padding-bottom:3.125%;background-color:#fff;box-shadow:0 3px 15px rgba(0,0,0,.5);-webkit-box-shadow:0 3px 15px rgba(0,0,0,.5);margin:20px auto;"> | |
<div style="margin-left: 3.334%;text-align:left;"> | |
<div style="padding-top:3.45%;padding-right:3.45%;"> |
This file contains 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
{ | |
"firstName": "John", | |
"middleName": "M", | |
"lastName": "Appleseed", | |
"age": 30, | |
"addresses":[ | |
{ | |
"streetAddress": "222 North Mountain Rd.", | |
"city": "Redwood City", | |
"state": "CA", |
This file contains 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
for(UILabel* label in self.allLabels){ | |
[label setText:NSLocalizedString(label.text, @"")]; | |
} |
NewerOlder