Post

Replies

Boosts

Views

Activity

Protocols and Associated Existential Types - Compiler and/or user problem?
Why is this ok …         let noCrash = controller.composer         let noCrashExtraStep = noCrash.document.title But this is not?  (Causes compiler crash — nonzero exit)         let crash = controller.composer.document.title Is this a bug in the compiler or am I missing some logic about protocols and associated types? Many thanks for any advice and also to the people who work on the Swift compiler.   Cheers Ventura / Xcode 14.1 beta 2 import SwiftUI // VIEWS @main struct CrashingApp: App { @StateObject var controller = ComposerController(composer: ConcreteComposer())     var body: some Scene {         WindowGroup {             ContentView()                 .environmentObject(controller)         }     }   } struct ContentView: View {     @EnvironmentObject var controller: ComposerController     var body: some View {         //  This line cannot be built without a crash         let crash = controller.composer.document.title                  //  If it's broken in two it works fine         let noCrash = controller.composer         let noCrashExtraStep = noCrash.document.title         Text(noCrashExtraStep)     } } // CONTROLLER class ComposerController: ObservableObject {        var composer: any ComposerProtocol     init(composer: any ComposerProtocol) {self.composer = composer } } // PROTOCOLS protocol ComposerProtocol {     associatedtype DocumentType: DocumentProtocol     var document: DocumentType {get set} } protocol DocumentProtocol {     var title: String { get set } } // CONCRETE TYPES struct ConcreteComposer: ComposerProtocol {     init() {document = ConcreteDocument()}     var document: ConcreteDocument } struct ConcreteDocument: DocumentProtocol {     var title: String = "Title" }
1
1
963
Sep ’22
SwiftUI Inspector ideal width
Should this not set the inspector width to 550 every time? TableView() .inspector(isPresented: $state.presented) { InspectorFormView(selection: model[state.selection]) .inspectorColumnWidth(min: 150, ideal: 550, max: 600) } This is almost verbatim from the WWDC video (10161). This ideal parameter will be the size of the column at at first launch, but if the user resizes the inspector, the system will persist that size across launches. Inspector uses the minimum width (150) in every case. How can the ideal width be guaranteed upon initial launch? I could set the minimum to 550, but I'd like the user to be able to reduce the size of the inspector as well ... Thanks much & keep inspecting!🧐 (Sonoma, beta 5 / Xcode beta 6)
1
0
1k
Aug ’23
MusicKit: Recent Items -- 30 item limit?
Using the MusicKit API to query the recent items seems to have a limit of 30 records. var searchRequest = MusicRecentlyPlayedRequest<Song>() Is this the true limit or is there another way? Using the Web Service API seems to have this limit too and is kind enough to document that. https://developer.apple.com/documentation/applemusicapi/get_recently_played_tracks I am interested in searching all history for certain tracks. The music library is good for checking songs played, but does not maintain tracks not in the library. Thank you for the assistance!
0
0
481
Aug ’23
MusicKit: URL to a song in user's Music Library in macOS?
I am looking for a way to get a URL to a MusicItemID/Song that is in the users music library after finding the song using MusicKit search. I would like the linked song to open the system music player. MusicCatalogSearchRequest has a link to the song, but MusicLibrarySearchRequest songs don't include a url. var searchRequest = MusicLibrarySearchRequest(term: searchTerm, types: [Song.self]) let s = try await searchRequest.response() resultSongURL = s.songs[0].song.url **alas, empty url** macOS also lacks access to SystemMusicPlayer when not using Catalyst. Thanks!
0
0
465
Aug ’23