Post

Replies

Boosts

Views

Activity

Type ‘()’ cannot conform to ‘AccessibilityRotorContent’
Driving me nuts… I have a class called TrackPiece2 with a bunch of var’s in it… I have an array of these and I want to change a value in each TrackPiece2 of the array… but I am getting the error “Type ‘()’ cannot conform to ‘AccessibilityRotorContent’” on the ForEach line of func changeZoom below ` class TrackLayout2 {     var trackPieces: [TrackPiece2] = []     var drawOuterLines: Bool = false          func addTrackPiece(newTrkPc: TrackPiece2) {         self.trackPieces.append(newTrkPc)     }          func changeZoom(newZoom: CGFloat) {         ForEach(trackPieces) {             trkPc in             trkPc.zoom = newZoom         }     }          func loadTrackPieces() {         let centerPoint = CGPoint(x: 160, y:160)                  addTrackPiece(newTrkPc: TrackPiece2(centerPnt: centerPoint, radius: 160.0, width: 10.0, startAngle: Angle(degrees: 0), angleArc: Angle(degrees: 45), color: Color.pink, zoom: 0.5))     } } ` Thanks for any advice/help… TJ
3
0
2.7k
Apr ’22
SwiftUI NSOpenPanel runs but then crashes Mac app
I have a SwiftUI Mac app I am writing... it starts out by calling a func (fileOpenDialog) that calls NSOpenPanel.runModal()... The NSOpenPanel shows and lets me choose a file... but then crashes the app on Open. If I don't use NSOpenPanel and just hardcode a file path, everything works fine. import SwiftUI struct DialogsTestView: View { var csvURLString = fileOpenDialog()[0]?.path // var csvURLString = "/Users/tj4shee/track.csv" func fileOpenDialog() -> [URL?] { let openPanel = NSOpenPanel() openPanel.title = "Choose csv file" openPanel.message = "Choose the csv file you want to convert to JSON" openPanel.showsResizeIndicator = false openPanel.allowedContentTypes = [UTType.delimitedText] openPanel.showsHiddenFiles = false openPanel.canChooseFiles = true openPanel.canChooseDirectories = false openPanel.allowsMultipleSelection = false let results = openPanel.runModal() return results == .OK ? openPanel.urls : [] } Thanks for any help, TJ
2
0
991
May ’22
Core Data - How to delete ONLY the relationship link between 2 entities
This is driving me nuts and I can't find anything where someone else has asked the same question. It can't be an unusual situation. I have a Student entity and a Classes entity and both are bi-directional Student<<-->>Classes A Student can be assigned to many Classes and Classes can have many students When a Student drops out of a given class, I want to remove the link between the particular student and the class - but without deleting either the student or the class objects. All my attempts have deleted either the student or the class object. How do I remove the relationship without removing the objects ? Is it possible ? In the interim I guess I can create a new entity... a 2 field table that links student and class... 1 to 1... then just delete the individual records to break a link... sounds like a lot of extra overhead though for what's supposed to be relational
1
0
1.5k
Jul ’22
SwiftUI Text View frame ignoring minWidth & idealWidth
Trying to get a Text View to keep a minimum width for short strings... but it seems to ignore minWidth and idealWidth when any frame is stated. Taking the frame out of the picture, everything works as expected. Xcode 13.4.1, getting exact same result on Mac Catalyst, made for iPad, iPad and iPhone. Target is iOS 15.4 Am I just misunderstanding min/ideal/max ? struct QuickTest: View { func viewSizeReader() -> some View { return GeometryReader { geometry -> Color in let rect = geometry.frame(in: .local); print(rect); return .clear }} var body: some View { VStack(spacing: 0) { HStack(spacing: 0) { Text("A very looooong string to test with") .frame(minWidth: 5, idealWidth: 5, maxWidth: 100, alignment: .leading) .lineLimit(1) .border(.red, width: 1) .background(viewSizeReader()) Text("short") .frame(minWidth: 5, idealWidth: 5, maxWidth: 100, alignment: .leading) .lineLimit(1) .border(.red, width: 1) .background(viewSizeReader()) Spacer() } Spacer() } } }
1
0
2.5k
Jul ’22