Post

Replies

Boosts

Views

Activity

Reply to Visualisation Revisited playground
You haven't shown the errors messages. Show what you've tried, what you expected to happen, what actually happened. Please post code as text (formatted as a code block), it makes it easier for us to quote later - screenshots are only useful for graphics. From the screenshot "makePieChart" creates an instance of a PieChartView named pieChartView". Which suggests there is some code somewhere which calls makePieChart and names the resulting view, like this: let pieChartView = makePieChart() "PieChartView has one property named wedges, an array of PieWedgeInstances. Assign an array pieChartView.wedges = [ PieWedge(proportion: 3, color: .black, scale: 0.5, offset: 0.5), PieWedge(proportion: 3, color: .black, scale: 0.5, offset: 0.5), PieWedge(proportion: 3, color: .red) ] or use the append method of Array to add them one at a time pieChartView.wedges.append(PieWedge(proportion: 3, color: .black, scale: 0.5, offset: 0.5)) pieChartView.wedges.append(PieWedge(proportion: 3, color: .black, scale: 0.5, offset: 0.5)) pieChartView.wedges.append(PieWedge(proportion: 3, color: .red) I hope this helps. Stick at it!
Topic: Programming Languages SubTopic: Swift Tags:
Feb ’23
Reply to Incorrect value in decibel measurement AVFoundation
what values are you comparing? The var decibels returned by audioRecorder.peakPower, or your own self.decibels? The value returned by AVAudioRecorder is already in units of dB. It is a relative power, not amplitude measurement. So if you expect your noise to be at 80dB below full scale, its power is at 40dB below full scale. So you might expect decibels to have a value of around -40. I don't think you should be converting twice. Also, you're using the a dB conversion formula appropriate for amplitude, not power. pow(10, (-40/20)) is equal to 0.01, which is of the order of magnitude you are seeing. Your other measurements (20dB "silence", 50dB "noise") appear to be amplitude measurements relative to some stable (low) level.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Mar ’23
Reply to Xcode preview crashing
this is really late but I got here because my previews are crashing (for some other reason) The reason this one is crashing is because the second call to padding is missing the period before it. So padding() is simply a call to the padding() function on ContentView, which causes infinite recursion. The .padding() modifier should be applied to the second HStack.
Mar ’23
Reply to Overlaid items hide behind neighbouring views
the code in your body is executed in the order you write it. Your first ForEach draws each row from the top downwards. Each row contains a TileView (a brown or yellow square) and a pieceView, which may draw nothing at all, but if it draws something, it is an overlay drawn below the tile (if the offset is negative). The next row you draw will draw over that overlay. To fix this, make the content something like this ZStack { BoardView() PiecesView() } The BoardView doesn't change as your chess game changes. The PiecesView would be dependent on the model of the chess game as it progresses. If it were me, I'd iterate through all the pieces in the game, and draw them at their respective x,y offsets. Your pieceView function looks up a pieceView based on the current co-ordinate on the board, but it does so at a different co-ordinate for each square, then applies an offset from that square when drawing the overlay. I think I'd prefer to be drawing at an offset from a fixed location, like the bottom left of the board.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Mar ’23
Reply to Overlaid items hide behind neighbouring views
I played around a bit with zIndex. It applies to the rendering order within one View, it isn't global. It would be Really Hard to make a system where it is global - you can't predict what other Views are using for their zIndex values. Normally the rendering order is dictated by the order of appearance in the View's description. I can only see an application for zIndex if you are parameterizing the rendering order. If the zIndex is a constant you may as well just write the View's description in a different order.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Mar ’23
Reply to Unexpected Error
someone will be able to help you if you post the code itself, rather than a screenshot of a fragment of it (format it as code so it is readable). It seems that you wrote an init() function that does nothing. In the struct or class which you are initializing, there are properties declared like this: var whatever: String or var somethingElse: Float for example Either declare them with initial values var whatever = "Hello" var somethingElse = 1.0 or give them values in your init(), perhaps like this init() { whatever = "goodbye" somethingElse = someThingComplicatedThatReturnsAFloat() }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’23
Reply to Trailing closure passed to parameter of type 'FormStyleConfiguration' that does not accept a closure
what code do you have a problem with? The unformatted code, or the code in the code block? The unformatted code works for me, but I had to replace $user.user?.firstName ?? "" with $firstName, where I declared a @State private var firstName = "Joe", and similarly for lastName. The formatted code shouldn't compile, because Int() returns an Int, while ``TextField's text: parameter should be a Binding<String> Try simplifying your code to something you can post as a complete sample. That alone may lead you to a solution. If it doesn't, post the complete sample here and indicate clearly what is not working (you said "in the title on the following form", but there is no "title" field). Also mention what platform (macOS, iOS etc) you are targeting, and what Xcode version you are using.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’23
Reply to MAC address
iOS 7 release notes are archived here https://developer.apple.com/library/archive/releasenotes/General/WhatsNewIniOS/Articles/iOS7.html#//apple_ref/doc/uid/TP40013162-SW1 search for "MAC address" on that page
Topic: App & System Services SubTopic: Core OS Tags:
Apr ’23