Post

Replies

Boosts

Views

Activity

Reply to @State not updating when set via .init([...]) parameter
But if you change __internalNumber from @State to @Binding it will bind to any changes as a result of any external @State side effects. public struct TestView: View {     var number: Int     @Binding private var _internalNumber: Int     public init(number: Int) {         self.number = number         self.__internalNumber = Binding.constant(number) // bind __internalNumber to changes of the external @State variable     }   public var body: some View {     VStack(alignment: .leading) {       Text("number: \(number)")       Text("internal: \(_internalNumber)")     }     .debugAction {       Self._printChanges()       print("number: \(number)")       print("_internalNumber: \(_internalNumber)")     }   } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’22
Reply to Dynamic list sections with observed data with SwiftUI
I ran your code with Xcode 13.4.1 & iOS 15.5 and it works as expected and not as described: one thing I will do is sort the data at source         self.objectList = [             Testclass(name: "A1"),             Testclass(name: "B1"),             Testclass(name: "Z2"),             Testclass(name: "C1"),             Testclass(name: "D1"),             Testclass(name: "D2"),             Testclass(name: "A2"),             Testclass(name: "Z1")         ].sorted(by: {$0.name < $1.name})
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’22
Reply to State change doesn't affect TextField lineLimit UI in Xcode 14 Beta
I have not tested this but give it a try SB import SwiftUI struct TextFieldDynamicHeight: ViewModifier {     var fullSize: Binding<Bool> = .constant(false)     var upperRange: ClosedRange<Int>     var lowerRange: ClosedRange<Int>     var upperBound: Int     var lowerBound: Int     func body(content: Content) -> some View {         if #available(iOS 16.0, *) {             content                 .lineLimit(fullSize.wrappedValue ? upperRange : lowerRange)         } else {             content                 .lineLimit(fullSize.wrappedValue ? upperBound : lowerBound)         }     } } extension View {     @available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)     func lineLimit(_ fullSize: Binding<Bool>, upperRange: ClosedRange<Int>, lowerRange: ClosedRange<Int>) -> some View {         modifier(TextFieldDynamicHeight(fullSize: fullSize, upperRange: upperRange, lowerRange: lowerRange,                                         upperBound: 0, lowerBound: 0))     }     @available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)     func lineLimit(_ fullSize: Binding<Bool>, upperBound: Int, lowerBound: Int) -> some View {         modifier(TextFieldDynamicHeight(fullSize: fullSize, upperRange: 0...0, lowerRange: 0...0,                                         upperBound: upperBound, lowerBound: lowerBound))     } } struct ContentView: View {     @State private var description: String = ""     @State private var fullSize: Bool = false     @State private var fullHeight: Bool = false     var body: some View {         VStack {             VStack {                 Image(systemName: "globe")                     .imageScale(.large)                     .foregroundColor(.accentColor)                 Text("Hello world!")             }             if #available(iOS 16.0, *) {                 TextField("Type a textmail", text: $description, axis: .vertical)                     .lineLimit($fullSize, upperRange: 2...6, lowerRange: 2...3)                     .foregroundColor(.white)                     .background(Color.blue)                     .frame(height: fullHeight ? 300 : 100)                     .padding(0)             } else {                 TextField("Type a textmail", text: $description)                     .lineLimit($fullSize, upperBound:6, lowerBound: 3)                     .foregroundColor(.white)                     .background(Color.blue)                     .frame(height: fullHeight ? 300 : 100)                     .padding(0)             }             Button("Full size") {                 fullSize.toggle()                 print("fullSize: \(fullSize)")             }             .padding(5)             Button("Full height") {                 fullHeight.toggle()                 print("fullHeight: \(fullHeight)")             }             .padding(5)         }     } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’22
Reply to @State not updating when set via .init([...]) parameter
But if you change __internalNumber from @State to @Binding it will bind to any changes as a result of any external @State side effects. public struct TestView: View {     var number: Int     @Binding private var _internalNumber: Int     public init(number: Int) {         self.number = number         self.__internalNumber = Binding.constant(number) // bind __internalNumber to changes of the external @State variable     }   public var body: some View {     VStack(alignment: .leading) {       Text("number: \(number)")       Text("internal: \(_internalNumber)")     }     .debugAction {       Self._printChanges()       print("number: \(number)")       print("_internalNumber: \(_internalNumber)")     }   } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’22
Reply to Swift Playground - Round up the switches (using While & if conditions)
I'm here wondering as well, I don't see a prior question but it seems they're assuming someone else is doing the same exercise as them.
Replies
Boosts
Views
Activity
Jun ’22
Reply to Get Wifi List to connect Wifi Bridge to internet via React Native App
See here -> https://developer.apple.com/documentation/networkextension
Replies
Boosts
Views
Activity
Jun ’22
Reply to Get Wifi List to connect Wifi Bridge to internet via React Native App
And sample code here (entitlement to use services is required from Apple) https://developer.apple.com/documentation/networkextension/configuring_a_wi-fi_accessory_to_join_the_user_s_network
Replies
Boosts
Views
Activity
Jun ’22
Reply to Framework ProximityReader
Follow the entitlement request URL in the documentation
Topic: Code Signing SubTopic: Entitlements Tags:
Replies
Boosts
Views
Activity
Jun ’22
Reply to No such module 'Amplify' & Could not read serialized diagnostics file: error("Invalid diagnostics signature")
The error message is pointing you to the solution. Open ApiService.swift and look for the import statement import Amplify remove it or make sure the module, framework or library is added to the project correctly.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’22
Reply to Dynamic list sections with observed data with SwiftUI
I ran your code with Xcode 13.4.1 & iOS 15.5 and it works as expected and not as described: one thing I will do is sort the data at source         self.objectList = [             Testclass(name: "A1"),             Testclass(name: "B1"),             Testclass(name: "Z2"),             Testclass(name: "C1"),             Testclass(name: "D1"),             Testclass(name: "D2"),             Testclass(name: "A2"),             Testclass(name: "Z1")         ].sorted(by: {$0.name < $1.name})
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’22
Reply to Sidebar inset spacing changes on rotation and reload - SwiftUI
Maybe give the ContentView your root view, some padding.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’22
Reply to Creating custom synchronization primitives with priority inheritance
File a bug report
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Jun ’22
Reply to There is a problem with Swift Error type check on iOS16 beta.
I've tested your findings above and this does look like an issue of a potential String: Error {} extension conformance. The most we can do is wait and see where the Beta revisions take us with the implementation SFError.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jun ’22
Reply to Poor Performance of Sample code from "Counting human body action repetitions in a live video feed"
This is Beta software so anything is expected at this point of time if running any of the Beta tools or OSes.
Topic: Machine Learning & AI SubTopic: General Tags:
Replies
Boosts
Views
Activity
Jun ’22
Reply to IOS-Stocks application similar UI gesture
Adding Gestures to a 3rd party library can cause unexpected side effects if not supported by the very same 3rd party library. Consult the 3rd party site/Github project or documentation on what is and is not supported by their framework.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jun ’22
Reply to I would avoid Xcode 14 (seems to have corrupted my system)
Git SCM is usually the way to go by branching your code into maybe an Xcode 14 branch where all work related to Xcode 14 takes place in there and some other branch from develop is where normal Xcode 13 or feature development continues to take place.
Replies
Boosts
Views
Activity
Jun ’22
Reply to State change doesn't affect TextField lineLimit UI in Xcode 14 Beta
I have not tested this but give it a try SB import SwiftUI struct TextFieldDynamicHeight: ViewModifier {     var fullSize: Binding<Bool> = .constant(false)     var upperRange: ClosedRange<Int>     var lowerRange: ClosedRange<Int>     var upperBound: Int     var lowerBound: Int     func body(content: Content) -> some View {         if #available(iOS 16.0, *) {             content                 .lineLimit(fullSize.wrappedValue ? upperRange : lowerRange)         } else {             content                 .lineLimit(fullSize.wrappedValue ? upperBound : lowerBound)         }     } } extension View {     @available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)     func lineLimit(_ fullSize: Binding<Bool>, upperRange: ClosedRange<Int>, lowerRange: ClosedRange<Int>) -> some View {         modifier(TextFieldDynamicHeight(fullSize: fullSize, upperRange: upperRange, lowerRange: lowerRange,                                         upperBound: 0, lowerBound: 0))     }     @available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)     func lineLimit(_ fullSize: Binding<Bool>, upperBound: Int, lowerBound: Int) -> some View {         modifier(TextFieldDynamicHeight(fullSize: fullSize, upperRange: 0...0, lowerRange: 0...0,                                         upperBound: upperBound, lowerBound: lowerBound))     } } struct ContentView: View {     @State private var description: String = ""     @State private var fullSize: Bool = false     @State private var fullHeight: Bool = false     var body: some View {         VStack {             VStack {                 Image(systemName: "globe")                     .imageScale(.large)                     .foregroundColor(.accentColor)                 Text("Hello world!")             }             if #available(iOS 16.0, *) {                 TextField("Type a textmail", text: $description, axis: .vertical)                     .lineLimit($fullSize, upperRange: 2...6, lowerRange: 2...3)                     .foregroundColor(.white)                     .background(Color.blue)                     .frame(height: fullHeight ? 300 : 100)                     .padding(0)             } else {                 TextField("Type a textmail", text: $description)                     .lineLimit($fullSize, upperBound:6, lowerBound: 3)                     .foregroundColor(.white)                     .background(Color.blue)                     .frame(height: fullHeight ? 300 : 100)                     .padding(0)             }             Button("Full size") {                 fullSize.toggle()                 print("fullSize: \(fullSize)")             }             .padding(5)             Button("Full height") {                 fullHeight.toggle()                 print("fullHeight: \(fullHeight)")             }             .padding(5)         }     } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’22
Reply to Xcode Cloud - machines
Treat it as a black box - you don't need to know.
Replies
Boosts
Views
Activity
Jun ’22