Post

Replies

Boosts

Views

Activity

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 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 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 XCode 14.2 randomly crashes often since update to Ventura
If Xcode itself is crashing, file a bug, this will tell you how. https://developer.apple.com/bug-reporting/ If your program is crashing, and you want help on this forum, you'll want to post relevant code samples, after you've gone some way to investigate the problem yourself. Start here. https://developer.apple.com/documentation/xcode/diagnosing-and-resolving-bugs-in-your-running-app
Jan ’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.
Replies
Boosts
Views
Activity
Mar ’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:
Replies
Boosts
Views
Activity
Mar ’23
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:
Replies
Boosts
Views
Activity
Feb ’23
Reply to Problems with ForEach, SwiftUI
your view model is publishing an array (a random access collection of artworks), but your ArtworkGridView declares a single var artwork: Artwork . You're asking ForEach to iterate over something that isn't a collection.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jan ’23
Reply to XCode 14.2 randomly crashes often since update to Ventura
If Xcode itself is crashing, file a bug, this will tell you how. https://developer.apple.com/bug-reporting/ If your program is crashing, and you want help on this forum, you'll want to post relevant code samples, after you've gone some way to investigate the problem yourself. Start here. https://developer.apple.com/documentation/xcode/diagnosing-and-resolving-bugs-in-your-running-app
Replies
Boosts
Views
Activity
Jan ’23