Post

Replies

Boosts

Views

Created

[SwiftUI] Slider text is not appearing at all
The sliders themselves are rendered, but not the text no matter what I try. Here is my code for reference: var body: some View { ScrollView { Text("Synth View") .font(.system(size: 55, weight: .semibold, design: .rounded)) .padding(.bottom) VStack { Button( "Trumpet", action: { modulatingMultiplier = 10 frequency = 200 carrierMod = 5 index = 440 amplitude = 10 } ) LineGraph(data: data, maxData: maxData, minValue: graphMinValue, maxValue: graphMaxValue) .clipped() .background(Color.accentColor.opacity(0.1)) .cornerRadius(20) .padding() .aspectRatio(1, contentMode: .fit) VStack { Slider(value: $frequency, in: 0...20000) { Text("Frequency").padding(.horizontal) } Slider(value: $modulatingMultiplier, in: 0...1000) { Text("Modulating Multiplier").padding(.horizontal) } Slider(value: $carrierMod, in: 0...1000) { Text("Carrier Mod").padding(.horizontal) } Slider(value: $amplitude, in: 0...1000) { Text("Amplitude").padding(.horizontal) } Slider(value: $index, in: 0...1000) { Text("Modulation Index").padding(.horizontal) } }.padding(.horizontal).frame(width: 600) } .onAppear { detector.onUpdate = { data.append(Double(detector.pitch) * 0.01) detector.setFrequency(Frequency : frequency, modulatingMultiplier : modulatingMultiplier, Amplitude: amplitude, cMult : carrierMod, index : index) } } } }
1
0
1k
May ’23
Objective-C copy properties
When I have a property like this: @property (nonatomic, readonly, copy) NSURL *sourceURL; And then I call: NSURL *url = self.sourceURL; Assuming that ARC is disabled, to ensure this object does not leak, must I manually release url? If so, how come I don't have to with: NSURL *url = [NSURL URLWithString:@"http://www.apple.com"]; NSURL *absURL = url.absoluteURL; Despite the absoluteString property also being readonly and copy: As per Apple: @property(nullable, readonly, copy) NSURL *absoluteURL;
2
0
1.8k
Apr ’23
ARC and init
I heard that "Methods starting with init or new or containing copy transfer, by definition, ownership; all other methods do not. Does this apply to ALL methods with the word "init" in the name, even if the function is "initialCapitalizationMode", in which initial does not mean the same as init? Or does it only work if it has "init" and then an uppercase letter after the fact?
2
0
765
Apr ’23
Toll-free bridging
Assume this code is compiled under ARC: BOOL method(unsigned a) { NSString *string = [[NSString alloc] initWithCString:"hi"]; if (a & 1 == 1) { CFStringRef CF = (CFStringRef)CFBridgingRetain(string); printf("%s", CFStringGetCStringPtr(CF, kCFStringEncodingUTF8)); CFRelease(CF); } } Will string get over-released in this example? What if I did the reverse? BOOL method(unsigned a) { CFStringRef string = CFStringCreateWithCString(NULL, "Hello World!", kCFStringEncodingUTF8); if (a & 1 == 1) { NSString *ns = (NSString *)CFBridgingRelease(string); printf("%s", CFStringGetCStringPtr(CF, kCFStringEncodingUTF8); } if (string) CFRelease(string); }
3
0
940
Mar ’23
Porting Games to Older Apple Platforms
Sadly, I was not able to register for the Games Q&A at. WWDC. My question is as follows: For making a Universal Binary, one compatible with Big Sur and up, will the tools in Xcode 15 help me port over a Win32 project over, or does the tool only work assuming macOS Sonoma and up, exclusively on Apple Silicon?
Replies
1
Boosts
0
Views
2.4k
Activity
Jun ’23
[SwiftUI] Slider text is not appearing at all
The sliders themselves are rendered, but not the text no matter what I try. Here is my code for reference: var body: some View { ScrollView { Text("Synth View") .font(.system(size: 55, weight: .semibold, design: .rounded)) .padding(.bottom) VStack { Button( "Trumpet", action: { modulatingMultiplier = 10 frequency = 200 carrierMod = 5 index = 440 amplitude = 10 } ) LineGraph(data: data, maxData: maxData, minValue: graphMinValue, maxValue: graphMaxValue) .clipped() .background(Color.accentColor.opacity(0.1)) .cornerRadius(20) .padding() .aspectRatio(1, contentMode: .fit) VStack { Slider(value: $frequency, in: 0...20000) { Text("Frequency").padding(.horizontal) } Slider(value: $modulatingMultiplier, in: 0...1000) { Text("Modulating Multiplier").padding(.horizontal) } Slider(value: $carrierMod, in: 0...1000) { Text("Carrier Mod").padding(.horizontal) } Slider(value: $amplitude, in: 0...1000) { Text("Amplitude").padding(.horizontal) } Slider(value: $index, in: 0...1000) { Text("Modulation Index").padding(.horizontal) } }.padding(.horizontal).frame(width: 600) } .onAppear { detector.onUpdate = { data.append(Double(detector.pitch) * 0.01) detector.setFrequency(Frequency : frequency, modulatingMultiplier : modulatingMultiplier, Amplitude: amplitude, cMult : carrierMod, index : index) } } } }
Replies
1
Boosts
0
Views
1k
Activity
May ’23
Objective-C copy properties
When I have a property like this: @property (nonatomic, readonly, copy) NSURL *sourceURL; And then I call: NSURL *url = self.sourceURL; Assuming that ARC is disabled, to ensure this object does not leak, must I manually release url? If so, how come I don't have to with: NSURL *url = [NSURL URLWithString:@"http://www.apple.com"]; NSURL *absURL = url.absoluteURL; Despite the absoluteString property also being readonly and copy: As per Apple: @property(nullable, readonly, copy) NSURL *absoluteURL;
Replies
2
Boosts
0
Views
1.8k
Activity
Apr ’23
ARC and init
I heard that "Methods starting with init or new or containing copy transfer, by definition, ownership; all other methods do not. Does this apply to ALL methods with the word "init" in the name, even if the function is "initialCapitalizationMode", in which initial does not mean the same as init? Or does it only work if it has "init" and then an uppercase letter after the fact?
Replies
2
Boosts
0
Views
765
Activity
Apr ’23
Toll-free bridging
Assume this code is compiled under ARC: BOOL method(unsigned a) { NSString *string = [[NSString alloc] initWithCString:"hi"]; if (a & 1 == 1) { CFStringRef CF = (CFStringRef)CFBridgingRetain(string); printf("%s", CFStringGetCStringPtr(CF, kCFStringEncodingUTF8)); CFRelease(CF); } } Will string get over-released in this example? What if I did the reverse? BOOL method(unsigned a) { CFStringRef string = CFStringCreateWithCString(NULL, "Hello World!", kCFStringEncodingUTF8); if (a & 1 == 1) { NSString *ns = (NSString *)CFBridgingRelease(string); printf("%s", CFStringGetCStringPtr(CF, kCFStringEncodingUTF8); } if (string) CFRelease(string); }
Replies
3
Boosts
0
Views
940
Activity
Mar ’23
Are apps made with swift playgrounds compiled?
Originally, we relied on xcode to compile apps and send them to the App Store. However, with iPads now having the ability to make apps, are these apps compiled in the same way or is there something else going on?
Replies
0
Boosts
0
Views
969
Activity
Jun ’21
accessing an objective-C’s class members via swift
some of my project’s objective c classes have structs with members. How do I access those members in swift?
Replies
1
Boosts
0
Views
759
Activity
Jun ’21
Can clang detect restricted pointers without the restricted keyword
The restrict keyword is rarely used in c applications and frameworks. Can clang automatically detect pointers that are mutually exclusive and optimize according to such or is the keyword needed for such optimizations? Finally does macos and iOS have their functions in C optimized like this as well?
Replies
1
Boosts
0
Views
1.2k
Activity
Jun ’21