Post

Replies

Boosts

Views

Activity

Reply to Binding issue
Short answer If you are using Binding<SomeType>, then use wrappedValue If you are using @Binding propertyWrapper then using just the variable name should give the value Long Answer import SwiftUI struct Something { //This is using the Binding propertyWrapper @Binding var price1: Int func f1() { price1 //Int value $price1 //Binding to the Int let price2 = $price1 //Type of price2 is Binding<Int> price2.wrappedValue //Int value } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’22
Reply to Rewrite UIKit to SwiftUI
If you are new to SwiftUI it might be best to invest some time understanding the fundamentals of SwiftUI. It is different from UIKit, if you invest time up front you would save time on the long run. WWDC has some great content for SwiftUI, you could start with https://developer.apple.com/wwdc20/10119 and https://developer.apple.com/wwdc20/10040. Once you are done with it you can view other links under the videos.
Topic: UI Frameworks SubTopic: UIKit Tags:
Jun ’22
Reply to NavigationStack and NavigationSplitView Runtime warnings
Confusion about NavigationSplitView There seem to be 2 ways: Option 1: WWDC video (https://developer.apple.com/wwdc22/10054) uses NavigationLink for NavigationSplitView Option 2: Documentation (https://developer.apple.com/documentation/swiftui/navigationsplitview) they don't use NavigationLink Not sure what is the correct approach, using NavigationLink seems to require navigationDestination but that doesn't sit well with NavigationSplitView as the destination view is specified part of the detail closure and repeating the code would be redundant. Following the documentation (without NavigationLink): Following https://developer.apple.com/documentation/swiftui/navigationsplitview documentation things seem to work ok, there is only one warning thrown (as opposed to 3 before): Update NavigationAuthority bound selection tried to update multiple times per frame. The other 2 warnings about navigationDestination and Focus are not thrown I really wish someone from the Apple team could clarify on this, please.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’22
Reply to Binding issue
Short answer If you are using Binding<SomeType>, then use wrappedValue If you are using @Binding propertyWrapper then using just the variable name should give the value Long Answer import SwiftUI struct Something { //This is using the Binding propertyWrapper @Binding var price1: Int func f1() { price1 //Int value $price1 //Binding to the Int let price2 = $price1 //Type of price2 is Binding<Int> price2.wrappedValue //Int value } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’22
Reply to NavigationSplitView sidebar Links not working after navigating back
Facing the same problem even on Xcode Beta 2
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’22
Reply to SwiftUI and @FetchRequest - modify predicate or sort dynamically?
@WeagleWeagle I have a scenario in which the initialiser to the view passes a value and depending on the value I need to determine the predicate and sort descriptors. Currently I have an if else statement and then I am setting self._items as suggested by @aharriscrowne For that scenario, is it ok to set self._items in the initialiser?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’22
Reply to Unboxing protocol to concrete type in SwiftUI View
IMHO it would be best to define what you are testing. If you are testing business logic, then it would be best to test only the model without SwiftUI code. You can be guaranteed the dependent views will change when the model changes
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’22
Reply to Rewrite UIKit to SwiftUI
If you are new to SwiftUI it might be best to invest some time understanding the fundamentals of SwiftUI. It is different from UIKit, if you invest time up front you would save time on the long run. WWDC has some great content for SwiftUI, you could start with https://developer.apple.com/wwdc20/10119 and https://developer.apple.com/wwdc20/10040. Once you are done with it you can view other links under the videos.
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Jun ’22
Reply to NavigationStack and NavigationSplitView Runtime warnings
Confusion about NavigationSplitView There seem to be 2 ways: Option 1: WWDC video (https://developer.apple.com/wwdc22/10054) uses NavigationLink for NavigationSplitView Option 2: Documentation (https://developer.apple.com/documentation/swiftui/navigationsplitview) they don't use NavigationLink Not sure what is the correct approach, using NavigationLink seems to require navigationDestination but that doesn't sit well with NavigationSplitView as the destination view is specified part of the detail closure and repeating the code would be redundant. Following the documentation (without NavigationLink): Following https://developer.apple.com/documentation/swiftui/navigationsplitview documentation things seem to work ok, there is only one warning thrown (as opposed to 3 before): Update NavigationAuthority bound selection tried to update multiple times per frame. The other 2 warnings about navigationDestination and Focus are not thrown I really wish someone from the Apple team could clarify on this, please.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’22
Reply to Strange SwiftUI bug (just making sure if it's a bug or not)
I think there is a typo .weigh after Image(systemName: "rectangle.portrait.and.arrow.right.fill")
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’22
Reply to swipeActions on macOS?
The key is to use a Label for it to work on macOS example: Text("aaa") .swipeActions { Button { //Do something } label: { Label("Delete", systemImage: "trash") //Use a label }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’22
Reply to Xcode Cloud Fails to build: Command exited with non-zero exit-code: 70
My scenario I had merged a lot of changes from a branch (pull request) I had also made changes to the swift package Problem Export archive for app-store distribution Command exited with non-zero exit-code: 70 Solution / Workaround Cleared DerivedData Cloned the project in a disk location
Replies
Boosts
Views
Activity
Jun ’22
Reply to Xcode Cloud not loading anymore
I am getting the "Could not load Xcode Cloud data" on macOS Monterey (12.5 Beta (21G5037d))
Replies
Boosts
Views
Activity
Jun ’22
Reply to Is it possible to set default height proportions of embedded views in VSplitView (MacOS)
You could add .frame modifier to set any height
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’22
Reply to List-like Selection for custom containers
I am not sure I understand your question correctly, contextMenu could be added to any custom view struct ContentView: View { var body: some View { Text("Hello, world!") .padding() .contextMenu { Button("aaa") {} } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’22
Reply to Large overlay
Use a ZStack instead of overlay ZStack { Text("Hello, world!") .padding() Rectangle() .fill(.red) }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’22
Reply to Reset the detail view on NavigationSplitView 3-column when a new Sidebar item is selected, but no content item
Remove Selection Can you set selectedRecipe = nil, that should remove any selection of the recipe. Selection of recipe is driven by the state variable selectedRecipe so depending on the value different recipes Reference: https://developer.apple.com/documentation/swiftui/list
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’22
Reply to NSSecureCoding allowed classes list
I have filed a feedback FB9793368 DTS has confirmed this is a bug, hope it gets fixed, fingers crossed
Replies
Boosts
Views
Activity
Jun ’22