At 24:56 in "Bring Core Data concurrency to Swift and SwiftUI" there's the following discussion:
But here's the important part. Changes to the request are committed whenever the results getter is called, so to update both the sorting and the sectioning safely...
I need to update the configuration on a reference to the results that I've pulled into a local.
The code in question is a property:
@SectionedFetchRequest(
sectionIdentifier: \.day,
sortDescriptors: [SortDescriptor(\Quake.time, order: .reverse)])
private var quakes: SectionedFetchResults<String, Quake>
And it is updated with:
.onChange(of: selectedSort) { _ in
let sortBy = sorts[selectedSort.index]
let config = quakes
config.sectionIdentifier = sortBy.section
config.sortDescriptors = sortBy.descriptors
}
It's unclear what the value/reference semantics here are. quakes looks like a value type, but this is clearly treating it as a reference type. But if it's a reference type, why is the config local variable important? It feels like some kind of magic is happening here.
Why is this local variable necessary, and how would I know this?
Post
Replies
Boosts
Views
Activity
I have a custom Instrument with a os-signpost-interval-schema that captures a "state" string. I would like the final plot value to be <state>: <duration>, but I don't know how to get the duration into the string.
My working schema is the following, which just stores the state itself in the column:
<os-signpost-interval-schema>
<id>state-interval</id>
<title>State Interval</title>
<subsystem>"..."</subsystem>
<category>"..."</category>
<name>"state"</name>
<start-pattern>
<message>?state</message>
</start-pattern>
<column>
<mnemonic>state</mnemonic>
<title>State</title>
<type>string</type>
<expression>?state</expression>
</column>
</os-signpost-interval-schema>
I would like to change the expression in the column to (str-cat ?state ": " ?duration), but that fails with:
Variable '?duration' must appear in a pattern element to be used in a later expression.
I don't see any way to compute this later in the graph, lane, or plot. I've also tried explicitly creating a <duration-column>, but that doesn't seem to change anything.
The rest of the pieces include the table:
<create-table>
<id>state-table</id>
<schema-ref>state-interval</schema-ref>
</create-table>
And the lane, which I would like to display as <state>: <duration> rather than just the duration:
<lane>
<title>State</title>
<table-ref>state-table</table-ref>
<plot>
<value-from>state</value-from>
</plot>
</lane>
I have a custom Instrument that is generally paired with Apple's HTTP Traffic instrument. Combining them in a template is inconvenient because there is no way to automatically filter to just the URLSession I want. The user must drill down into a long list of sessions and servers every time the instrument is run. The layout is also awkward because my Instrument's output is a long way from the specific HTTP track I want. Pinning these specific tracks is good, but has to be done every time and cannot be saved as a template.
I would like to extract the relevant information directly into my custom instrument, so just the information I want is visible, and in an order that is useful.
I can import the data from HTTPTracing and build my own tables, but is there a way to import the plot itself and reuse it? I would rather not have to re-implement Apple's fairly complex plot. If not, is there a way to access Apple's code for the HTTPTracing plots so that I can add it in my own instrument?