Posts

Post not yet marked as solved
2 Replies
890 Views
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?
Posted
by robnapier.
Last updated
.
Post not yet marked as solved
0 Replies
811 Views
I'm generating an audio file programmatically, and I'd like to add metadata to it, such as the title and artist. I don't particularly care what format the file is written in, as long as AVPlayer will read it and send it to the playing device. (The whole goal here is to get AVPlayer to send the track name for this generated song to a Bluetooth device. I'm happy to explore easier ways to achive this that don't require writing the file or adding metadata directly to the file.)I create my writer, and then setup my metadata: let writer = try AVAssetWriter(outputURL: output, fileType: .aiff) let title = AVMutableMetadataItem() title.identifier = .commonIdentifierTitle title.dataType = kCMMetadataBaseDataType_UTF8 as String title.value = "The Title" as NSString writer.metadata = [ title, ] // setup the input and write the file.The audio file writes without trouble, but the metadata isn't written. Audacity does seem to be able to write metadata to AIFF files. (I tried this originally with CAF files, but neither AVFoundation nor Audactiy wrote metadata in that case.)I've tried a lot of different approaches. I tried moving the metadata to the AVAssetWriterInput. I tried writing the artist rather than the title (just to see if title was the problem). I tried using "key" and "keyspace" rather than "identifier" for the metadata. I tried AVMetadataID3MetadataKeyLeadPerformer and AVMetadataiTunesMetadataKeySongName. In all cases I get no errors, but the metadata just isn't in the file. If I read the file by hand "The Title" doesn't appear anywhere.
Posted
by robnapier.
Last updated
.