Post

Replies

Boosts

Views

Activity

Reply to sort array of dictionaries
You can create a function which returns a Bool. Here's a simple example. let dict1 = ["Name" : "Wanda", "Age" : 32, "Gender" : "Female"] as [String : Any] let dict2 = ["Name" : "John", "Age" : 25, "Gender" : "Male"] as [String : Any] let dict3 = ["Name" : "Bob", "Age" : 15, "Gender" : "Male"] as [String : Any] let dict4 = ["Name" : "Jane", "Age" : 50, "Gender" : "Female"] as [String : Any] let dict5 = ["Name" : "Bill", "Age" : 75, "Gender" : "Female"] as [String : Any] var dictArray = [dict5, dict3, dict1, dict4, dict2] func dictSort(dict1: [String: Any], dict2: [String: Any]) -> Bool {     guard let i0 = dict1["Age"] as? Int,           let i1 = dict2["Age"] as? Int else {return false}     return i0 < i1 } var sortedArray = dictArray.sorted{dictSort(dict1: $0, dict2: $1)}
Topic: Programming Languages SubTopic: Swift Tags:
Jan ’22
Reply to Loading a RealityKit image texture from a URL
var myMaterial = PhysicallyBasedMaterial()         if let baseResource = try? TextureResource.load(named: "MyImage") {             // Create a material parameter and assign it.             let baseColor = MaterialParameters.Texture(baseResource)             myMaterial.baseColor = PhysicallyBasedMaterial.BaseColor(texture:baseColor)         }
Topic: Graphics & Games SubTopic: RealityKit Tags:
Mar ’22
Reply to Add a UIImage to a Plane in RealityKit
func placeImageModelEntity(imageAnchor: ARImageAnchor, width: Float, height: Float) {         let imageAnchorEntity = AnchorEntity(anchor: imageAnchor)         imageAnchorEntity.name = imageAnchor.name!         let screenMesh = MeshResource.generatePlane(width: width, depth: 1.33333*width, cornerRadius: 0.5)         var myMaterial = PhysicallyBasedMaterial()         if let baseResource = try? TextureResource.load(named: "MyImage") {             // Create a material parameter and assign it.             let baseColor = MaterialParameters.Texture(baseResource)             myMaterial.baseColor = PhysicallyBasedMaterial.BaseColor(texture:baseColor)         }         let imageModelEntity = ModelEntity(mesh: screenMesh, materials: [myMaterial])         let anchorWidth = imageAnchor.referenceImage.physicalSize.width         imageModelEntity.setPosition(SIMD3(x: Float(anchorWidth), y: 0, z: 0), relativeTo: imageAnchorEntity)         imageAnchorEntity.addChild(imageModelEntity)                  // Add anchor to scene         arView.scene.addAnchor(imageAnchorEntity)     }
Topic: Spatial Computing SubTopic: ARKit Tags:
Mar ’22
Reply to NavigationStack and NavigationSplitView Runtime warnings
I get the same console message. The only new method of NavigationLink that works with NavigationStack, at least for me, is the form. NavigationLink { MyDestinationView(data: data) } label: {            MyRowView(data: data) } However, I cannot go back in the navigation stack, only forward. No back buttons. But just this morning, I replaced NavigationStack with NavigationView and I had back buttons. I reworked all of my data to fit in the new form. I think that was a good thing anyway, so I want this to work. I could be messing up. Not sure. But with others having the same issue, it could be I'm doing this okay. We shall see.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jul ’22
Reply to NavigationStack and NavigationSplitView Runtime warnings
I created a very simple project as follows. NavigationLink("Go To Next View", value: "TheView")          .navigationDestination(for: String.self) { val in Text("Value = \(val)")          } This example worked in the simple project. But when I put this into my app's project using NavigationStack, I navigated to the next view fine, but had no back button.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jul ’22
Reply to Unable to symbolicate crash logs
I'm having the same issue, so I am very interested if anybody knows the answer to your question.
Replies
Boosts
Views
Activity
Dec ’21
Reply to sort array of dictionaries
You can create a function which returns a Bool. Here's a simple example. let dict1 = ["Name" : "Wanda", "Age" : 32, "Gender" : "Female"] as [String : Any] let dict2 = ["Name" : "John", "Age" : 25, "Gender" : "Male"] as [String : Any] let dict3 = ["Name" : "Bob", "Age" : 15, "Gender" : "Male"] as [String : Any] let dict4 = ["Name" : "Jane", "Age" : 50, "Gender" : "Female"] as [String : Any] let dict5 = ["Name" : "Bill", "Age" : 75, "Gender" : "Female"] as [String : Any] var dictArray = [dict5, dict3, dict1, dict4, dict2] func dictSort(dict1: [String: Any], dict2: [String: Any]) -> Bool {     guard let i0 = dict1["Age"] as? Int,           let i1 = dict2["Age"] as? Int else {return false}     return i0 < i1 } var sortedArray = dictArray.sorted{dictSort(dict1: $0, dict2: $1)}
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jan ’22
Reply to Loading a RealityKit image texture from a URL
var myMaterial = PhysicallyBasedMaterial()         if let baseResource = try? TextureResource.load(named: "MyImage") {             // Create a material parameter and assign it.             let baseColor = MaterialParameters.Texture(baseResource)             myMaterial.baseColor = PhysicallyBasedMaterial.BaseColor(texture:baseColor)         }
Topic: Graphics & Games SubTopic: RealityKit Tags:
Replies
Boosts
Views
Activity
Mar ’22
Reply to Add a UIImage to a Plane in RealityKit
func placeImageModelEntity(imageAnchor: ARImageAnchor, width: Float, height: Float) {         let imageAnchorEntity = AnchorEntity(anchor: imageAnchor)         imageAnchorEntity.name = imageAnchor.name!         let screenMesh = MeshResource.generatePlane(width: width, depth: 1.33333*width, cornerRadius: 0.5)         var myMaterial = PhysicallyBasedMaterial()         if let baseResource = try? TextureResource.load(named: "MyImage") {             // Create a material parameter and assign it.             let baseColor = MaterialParameters.Texture(baseResource)             myMaterial.baseColor = PhysicallyBasedMaterial.BaseColor(texture:baseColor)         }         let imageModelEntity = ModelEntity(mesh: screenMesh, materials: [myMaterial])         let anchorWidth = imageAnchor.referenceImage.physicalSize.width         imageModelEntity.setPosition(SIMD3(x: Float(anchorWidth), y: 0, z: 0), relativeTo: imageAnchorEntity)         imageAnchorEntity.addChild(imageModelEntity)                  // Add anchor to scene         arView.scene.addAnchor(imageAnchorEntity)     }
Topic: Spatial Computing SubTopic: ARKit Tags:
Replies
Boosts
Views
Activity
Mar ’22
Reply to Landmarks SwiftUI Tutorial - Creating watchOS App - Navigation Broken
I am having the same issue. Not only that; the Landmarks title doesn't display in the root view on the Apple Watch. I'm using Xcode 13.4.1. Has anybody found the fix?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’22
Reply to Landmarks SwiftUI Tutorial - Creating watchOS App - Navigation Broken
It works on an actual Apple Watch, but not on a simulator. Knowing it works on a device is a good thing.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’22
Reply to UIBarButtonItem With Image Breaks Constraints
The deployment target is iOS 16.
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Jul ’22
Reply to NavigationStack and NavigationSplitView Runtime warnings
I get the same console message. The only new method of NavigationLink that works with NavigationStack, at least for me, is the form. NavigationLink { MyDestinationView(data: data) } label: {            MyRowView(data: data) } However, I cannot go back in the navigation stack, only forward. No back buttons. But just this morning, I replaced NavigationStack with NavigationView and I had back buttons. I reworked all of my data to fit in the new form. I think that was a good thing anyway, so I want this to work. I could be messing up. Not sure. But with others having the same issue, it could be I'm doing this okay. We shall see.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jul ’22
Reply to Xcode Accounts Apple ID Unexpected Status Code
Now it appears to be working. I hope that I can relax now.
Replies
Boosts
Views
Activity
Jul ’22
Reply to NavigationStack and NavigationSplitView Runtime warnings
I created a very simple project as follows. NavigationLink("Go To Next View", value: "TheView")          .navigationDestination(for: String.self) { val in Text("Value = \(val)")          } This example worked in the simple project. But when I put this into my app's project using NavigationStack, I navigated to the next view fine, but had no back button.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jul ’22
Reply to NavigationStack - No Back Button
I'm hoping for some guidance, whether it's a known bug or whether there's something stupid that I am doing. I don't discount the latter, which is why I've been easter-egging my project, but I think it's the former.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jul ’22
Reply to Xcode Navigationlink not working
It would be clearer if you had embedded your code in a code block.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jul ’22
Reply to Xcode Navigationlink not working
I recommend using the init NavigationLink { DestinationView() } label: { LabelView() } The version you are using is deprecated in iOS 16.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jul ’22
Reply to Xcode Navigationlink not working
Why do you have VStacks within a VStack? It seems to me that you could ditch (get rid of) the inner VStacks.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jul ’22
Reply to NavigationStack - Missing Back Buttons
I filled a bug report on this. FB10908690 (NavigationStack - No Back Button)
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jul ’22