Post

Replies

Boosts

Views

Activity

Reply to Timeline Apple legal name dispute
I don't understand. You say you have a trademark on the name but also speak of The business owning the name currently … How could you get a valid trademark is the name is owned by someone else (even if out of business) ? Who owns the name at the end ? IMHO, delay does not depend on Appstore but on your legal battle resolution.
Apr ’24
Reply to List or a ForEach from a binding: keyboard issue
I tested and reproduced the problem, in simulator and on device.. Problem seems to be the association of List and TextEditor ; when typing, List cells or ForEach cells are resized, forcing keyboard to hide. Problem is not TextEditor itself, as this works properly if alone: struct ContentView: View { @State private var msg = "Hello" var body: some View { TextEditor(text: $msg) } } Note: same problem with TextField: List($messages, id: \.self) { $msg in TextField("A", text: $msg) } You may file a bug report.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’24
Reply to no data from userdefaults
Debug is possible. For instance, check if try succeeds: if let decoded = try? JSONDecoder().decode([RouteObject].self, from: data) { print("decode success") routes = decoded return } Try: if let data = UserDefaults.standard.data(forKey: saveKey) as? Data { // <<-- add as? data Could you also show how RouteObject is defined ?
Topic: App & System Services SubTopic: General Tags:
Apr ’24
Reply to How to get the position of dominant colors in CGImage?
An idea for a more basic solution: split each color axis (0 to 255) in segments with width of 4: 0-3; 4-7; 8-11 … You will have 64 segments. Then you create an array to count how many pixels in each of the 64 * 64 * 64 = 262144 items (if you split by 8, you can reduce to 323232 = 32768 var theCube : [Int] = Array(repeating: 0, count: 646464) a function to compute the position of a color in the array: func colorIndex(for color: UIColor) -> Int { // we return 64*64*r/4 + 64*g/4 + b/4, with r, g, b between 0 and 255 var index = 0 if let components = color.cgColor.components { if components.count < 3 { // We are grayscale, r, g, b will be equal let grayValue = Int(255*components[0] / 4) // We bring grayValue between 0 and 63 index = (64*64 + 64 + 1) * grayValue } else { // components are between 0 and 1, convert to 0...255 first index = 64*64*Int(255*components[0] / 4) index = index + 64 * Int(255*components[1] / 4) index = index + Int(255*components[2] / 4) } } return index } test: print(colorIndex(for: UIColor.red)) // 258048 print(colorIndex(for: UIColor.green)) // 4032 print(colorIndex(for: UIColor.blue)) // 63 print(colorIndex(for: UIColor.white)) // 262143 last item in cube print(colorIndex(for: UIColor.black)) // 0 first item in cube you then test for each pixel, computing the colorIndex and increment the cube[index] accordingly max value in the array is the dominant color: its index is dominantColorIndex. Once you have defined this dominant color search for points which color fall in this max, by computing its colorIndex and find if equal to dominantColorIndex Hope that helps.
Topic: Programming Languages SubTopic: Swift Tags:
Apr ’24
Reply to Broken Xcode
Your version of Xcode is so old (we are now 15.4) and MacOS 14, that it is not surprising that you get problems. Even rdar is no more accessible. Can't you really update MacOS to a more recent version and Xcode to a version supported by this OS version ?
Apr ’24
Reply to How to I move the sectorMark annotation to the outside perimeter of the pie chart?
The way I achieved it is by computing a position for the annotation. Here is the sample code for you to improve… struct ContentView: View { struct PieData: Identifiable { let id = UUID() let category: String let categoryPercentage: Int var angle = 0.0 // Will be computed onAppear var color: Color } @State private var pieData: [PieData] = [ .init(category: "A", categoryPercentage: 10, color: .blue), .init(category: "B", categoryPercentage: 68, color: .green), .init(category: "C", categoryPercentage: 20, color: .orange), .init(category: "D", categoryPercentage: 38, color: .brown), .init(category: "E", categoryPercentage: 98, color: .red), .init(category: "F", categoryPercentage: 58, color: .cyan), .init(category: "G", categoryPercentage: 77, color: .yellow) ] var angles: [Double] { var computedAngles = [Double]() var midSectorAngle = 0.0 let total = pieData.reduce(0, { $0 + $1.categoryPercentage }) // needed to compute angles var partialTotal = 0 for data in pieData { midSectorAngle = Double(partialTotal) + Double(data.categoryPercentage) / 2 midSectorAngle *= 2 * Double.pi / Double(total) computedAngles.append(midSectorAngle) partialTotal += data.categoryPercentage } return computedAngles } var body: some View { GeometryReader { geometry in Chart(pieData) { data in SectorMark(angle: .value("Pie Chart", data.categoryPercentage), angularInset: 1.7) .foregroundStyle(by: .value("Category", data.category)) .cornerRadius (5) .annotation (position: .overlay) { Text("\(data.categoryPercentage)%") .bold() .position(x: 145+75*sin(data.angle), y: 140-75*cos(data.angle)) } // .offset(x: 200, y: 20) // If here it would rotate sectors ! } .frame(width: 300, height: 300) .position(x: 200, y: 400) .onAppear { for index in 0..<pieData.count { pieData[index].angle = angles[index] } } } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’24