Post

Replies

Boosts

Views

Activity

Reply to SwiftUI Text View frame ignoring minWidth & idealWidth
FYI... I know there is a way around it (using something similar to the viewSizeReader func and a ZStack)... but from my perspective it just doesn't work the way I perceive it should. For anyone interested... This is a workaround struct QuickTest: View { @State var textWidth = CGFloat.zero func viewSizeReader() -> some View { return GeometryReader { geometry -> Color in print(geometry.frame(in: .local)); return .clear }} func viewWidthReader(_ binding: Binding<CGFloat>) -> some View { return GeometryReader { geometry -> Color in let rect = geometry.frame(in: .local) DispatchQueue.main.async { binding.wrappedValue = rect.size.width } return .clear } } var body: some View { VStack(spacing: 0) { HStack(spacing: 0) { Text("A very looooong string to test with") .frame(minWidth: 5, idealWidth: 50, maxWidth: 100, alignment: .leading) .lineLimit(1) .border(.red, width: 1) .background(viewSizeReader()) ZStack { Text("short") .fixedSize(horizontal: true, vertical: false) .foregroundColor(.clear) .lineLimit(1) .background(viewWidthReader($textWidth)) Text("short") .frame(width: textWidth) .lineLimit(1) .border(.red, width: 1) .background(viewSizeReader()) } Spacer() } Spacer() } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jul ’22
Reply to Core Data - How to delete ONLY the relationship link between 2 entities
Thank You to Joakim Danielson on StackOverflow ! The answer was there... I just wasn't aware... Core Data creates a func for the entity relationship. As an example, entity Students has a relationship named Classes (destination = Classes entity) entity Classes has a relationship named Students (destination = Students entity) Core Data creates a func for each of the entity relationships: .removeFromClasses() .removeFromStudents() these remove the relationship link from each of the respective relationships. In order to remove the relationship completely, I execute both func - the entity objects both remain but are no longer linked !
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jul ’22
Reply to SwiftUI NSOpenPanel runs but then crashes Mac app
A little more info... it seems to occur when trying to draw my view ??? This code successfully runs... prints "before", the contents of my file and "after"... then crashes before I see any view TextEditor(text: $csvText) .onAppear { do { print("before") csvText = try String(contentsOf: csvURL) print(csvText) print("after") } catch { print("Failure with \(csvURL.path)\nError: \(error)") } } but like I said, if I define csvURL by hardcoding a path in csvURLString... everything works fine
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’22