Post

Replies

Boosts

Views

Activity

ScrollView not working properly on macOS?
Hi, I have a very simple program (see below) with some Views in an HStack, which is within a ScrollView. This works fine on iOS, but on macOS nothing scrolls. Am I missing something? Shouldn't it just scroll? import SwiftUI struct ContentView: View { 	var body: some View { 		ScrollView(.horizontal, showsIndicators: true) { 			HStack { 				ItemView(n: 1) 				ItemView(n: 2) 				ItemView(n: 3) 				ItemView(n: 4) 				ItemView(n: 5) 			} 		} 		.frame(minWidth: 350, maxWidth: 800, minHeight: 250, maxHeight: 250, alignment: .center) 	} } struct ContentView_Previews: PreviewProvider { 	static var previews: some View { 		ContentView() 	} } struct ItemView: View { 	var n: Int 	 	var body: some View { 		Rectangle() 			.frame(width: 300, height: 200) 			.overlay(Text("\(n)").foregroundColor(.white)) 	} }
2
0
2.4k
Apr ’21
Crash in swift_getObjectType or processDefaultActor when using (nested) async/await with URLSession
Hi, when using URL session nested in a few async/await calls I get a crash in swift_getObjectType (sometimes in processDefaultActor). Any ideas what could be causing this or hints how to debug/where to look? For a (contrived - because it was extracted from a larger project) example please see below (see "crashes here" comment for the last call before the crash). Thanks for any hints in advance! Cheers, Michael // Crash on: Xcode Version 13.0 beta (13A5155e), macOS 11.4 (20F71), on iPhone Simulator import CoreData import SwiftUI struct ContentView: View { @StateObject var dataCoordinator: DataCoordinator = .init() var body: some View { Button { print("GO") async { try await dataCoordinator.api.getSomething() } } label: { Label("Go", systemImage: "figure.walk") } .buttonStyle(.bordered) } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView().environment(\.managedObjectContext, PersistenceController.preview.container.viewContext) } } // MARK: - Test coding - class DataCoordinator: ObservableObject { let api: API = .init() func refreshSomething() async throws { try await api.getSomething() } } // MARK: - class API { var session: URLSession = .init(configuration: .ephemeral) func getSomething() async throws { let url = URL(string: "https://www.heise.de")! let request = URLRequest(url: url) let (data, response) = try await _failsafe(request: request) print("\(response)") } private func _failsafe(request: URLRequest) async throws -> (Data, URLResponse) { do { var (data, response) = try await session.data(for: request) let httpResponse = response as! HTTPURLResponse var recovered = false if httpResponse.allHeaderFields["dsfsfsdsfds"] == nil { let login = LoginAsync() await login.login(session: session) recovered = true } if recovered { let req2 = URLRequest(url: URL(string: "https://www.heise.de")!) print("right before crash") try await session.data(for: req2) // crashes here with EXC_BAD_ACCESS print("right after crash ;-)") } return (data, response) } catch { print("\(error)") throw error } } } // MARK: - actor LoginAsync { func login(session: URLSession) async { let url = URL(string: "https://www.google.com")! let request = URLRequest(url: url) do { let (data, response) = try await session.data(for: request) } catch { print("\(error)") } } }
2
0
2.5k
Jul ’21
CoreData relationships in a child context are not isolated?
Hi, I am using a child NSManagedContext trying to isolate changes to a NSManagedObject from changes done to the same object in the parent NSManagedObjectContext. This works fine for normal properties, but any changes to relationships performed on the object in the parent context will show up immediately in the child object as well. Is this the intended behavior? If yes is there a way to create an "isolated" version of an NSManagedObject? Thanks in advance for any hints! Cheers, Michael
1
0
1.4k
Sep ’21
@SceneStorage not working on macOS
Hi, using the following ContentView in a SwiftUI app on macOS I would expect that the state of the toggle persists across application launches: struct ContentView: View { @SceneStorage("Toggle") var onOrOff: Bool = false var body: some View { VStack { Toggle("Will it persist?", isOn: $onOrOff) .padding() } } } To my surprise it does not persist. Am I wrong about how @SceneStorage should work? (I am trying this on the lates macOS/Xcode versions) Does @SceneStorage work for anybody on macOS? Thanks for your feedback! Cheers, Michael
4
0
2.5k
Sep ’23
Is migration working for anyone on Xcode beta6?
Hi, I am trying my first SwiftData migration, but my custom migration stage never gets called. Since I am not sure if this is a bug with the current beta of if I am "holding it wrong" I was wondering, if anybody got migration working (their MigrationStage.custom called)? Would be great, if you could just let me know, if you got it working or running into the same issue! :-) Thank you! Cheers, Michael
1
0
1.1k
Aug ’23