Post

Replies

Boosts

Views

Activity

Reply to How long can we use Xcode 11 for app updates?
So maybe I will not find out until we do a *real* release? I haven't checked how Apple's system works for newly submitted apps, you have an option to try it by yourself with your own risk. But anyway, if you submit your app built with Xcode 11, it is clearly against the Apple's announcement. (You can check old news and find that Apple used new application or updates when needed to distinguish them.) Please share your experience when you submit your update.
Apr ’21
Reply to How long can we use Xcode 11 for app updates?
It is unclear what the quoted paragraph means: does it mean new applications must be built with Xcode 12, or does it mean that any app update to existing applications must use Xcode 12? It is quite clear. When the term apps submitted to the App Store is used, it means all the apps submitted to the App Store, whether they are new applications or updates to existing applications.
Apr ’21
Reply to Getting picker selected value with api data
This is my complete code: Far from complete. Simply saying a complete code is a self contained code which can be built and run without any guesses. Sorry, didn't think that you'd need that as well If you could guess what is needed for readers properly, more readers would take time to solve your issue and you would get better responses sooner. You declare ID of MyModel as String, so the type of selection needs to match to it: struct MyView: View { @State var mydata = [MyModel]() @State private var ID: String = "" //- var body: some View { NavigationView { Form { Section { Picker("Pick an item", selection: $ID) { ForEach(mydata, id: \.ID) { mymodel in Text(mymodel.Name) //`name` or `Name` } }.onAppear(perform: loadData) Text("Selected: \(ID)") } } } } //... } Assuming your loadData() works properly. But generally, you should better not dispose error info silently: func loadData() { guard let url = URL(string: "https://mysite.co.uk/api/getmydatalist") else { print("Invalid URL") return } let request = URLRequest(url: url) URLSession.shared.dataTask(with: request) { data, response, error in if let error = error { print(error) return } guard let data = data else { print("data is nil") return } do { let response = try JSONDecoder().decode([MyModel].self, from: data) DispatchQueue.main.async { self.mydata = response } } catch { print(error) } }.resume() }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’21
Reply to What replaces there Tabbed template in Xcode 12?
How do you close a thread? There's no closing features in the dev forums. Better visit the support page - https://developer.apple.com/support/forums/ of the dev forums and learn what would be the right usage. If you think any of the replies (including yours) helped solving your issue, marking it as SOLVED would have similar effect as closing. Please be careful when marking a reply as SOLVED, once marked you cannot unmark it.
Topic: Programming Languages SubTopic: Swift Tags:
Apr ’21
Reply to UserDefaults with Struct - TableView not displaying data from saved from UserDefaults?
Please show full code. Fragments of code do not make sense. In which class person, tableView(_:numberOfRowsInSection:) and tableView(_:cellForRowAt:) are defined? How are you filling data into the property person? (Asking about the property person, not about the local variable person.) One more, please use the Code block feature (icon ``) when you want to show some codes.
Topic: Programming Languages SubTopic: Swift Tags:
Apr ’21
Reply to Value of type "PlaygroundKeyValueStore" has no member "keyValueStore"
Based on other descriptions in the doc, the code sample is a bit outdated. It should be something like this: // Store a value. PlaygroundKeyValueStore.current["animal"] = .string("Llama") // Retreive that same value. var theAnimal: String? = nil if let keyValue = PlaygroundKeyValueStore.current["animal"], case .string(let animalType) = keyValue { theAnimal = animalType } You can send a bug report of this documentation bug using Apple's Feedback Assistant.
Topic: Programming Languages SubTopic: Swift Tags:
Apr ’21
Reply to TabBar
Now I need to switch TabBar items, using the buttons on the View. How can I do this ? You may need to access the selection of TabView: struct ContentView: View { @State var tabSelection: Int = 1 var body: some View { TabView(selection: $tabSelection) { TabView1View(tabSelection: $tabSelection) .tabItem { Text("TabItem1") } .tag(0) TabView2View(tabSelection: $tabSelection) .tabItem { Text("TabItem2") } .tag(1) } } } struct TabView1View: View { @Binding var tabSelection: Int var body: some View { Button(action: { //call tabItem 2 self.tabSelection = 1 }) { Text("TabItem1") } } } struct TabView2View: View { @Binding var tabSelection: Int var body: some View { Button(action: { //call tabItem 1 self.tabSelection = 0 }) { Text("TabItem2") } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’21
Reply to Convert HTML to Text
As for now, there's no support for rendering HTML in SwiftUI. You may need to wrap WKWebView or UILabel with NSAttributedString into UIViewRepresentable. You can send a feature request using Apple's Feedback Assistant.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’21
Reply to How to Sum User-Generated Data
I'm trying to find the sum of a user-generated array by using the following code.  I have this structure on the top of the page with the following data format: Where is the array? To apply reduce, the thing applied needs to be an Array. (Or at least a Sequence.) In your shown code, there aren't any Arrays. Assuming you have an Array of Grade, var grades: [Grade] = [/*...*/] you can write something like this: let total = grades.reduce(0, {$0 + $1.pointsReceived}) By the way, why are you using Implicitly Unwrapped Optionals in your struct? If you know the property can be nil, you should use normal Optionals: struct Grade: Hashable, Identifiable { 		var id = UUID() 		var assessmentName: String? 		var pointsReceived: Double? 		var pointsPossible: Double? } (In this case, you need to update the code to reduce.) Or else, if the property cannot be nil, you should better use non-Optional: struct Grade: Hashable, Identifiable { 		var id = UUID() 		var assessmentName: String 		var pointsReceived: Double 		var pointsPossible: Double }
Topic: Programming Languages SubTopic: Swift Tags:
Apr ’21
Reply to Open Modal
Shoudn't the first click also to be passing the selectedEvento ? Why it doesnt happen ? It is a known issue that @State variables do not work when used in the closure of sheet. A possible workaround is making another View from the content of the sheet: struct MyView: View { //... var body: some View { //... .sheet(isPresented: $showModal) { MySheetView(selectedEvento: self.$selectedEvento) } //... } } struct MySheetView: View { @Binding var selectedEvento: Evento? var body: some View { if self.selectedEvento != nil { //open detailView } else { Text("Some Error State goes here") } } } You can find some other threads showing how to workaround the @State and sheet issue, for example: https://developer.apple.com/forums/thread/677454 .
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’21
Reply to Question: Swiftui http request without button
But I don't get how to use the Array" Dateien" from the Http-Request instead of the example one. It's dateien, not Dateien. In Swift, identifiers are case sensitive, you should better care about that even in non-code context. Assume your print(dateien) (line 85 of doHttpRequest()) shows expected result, you just need to update the property dateien with the local variable dateien. 				self.dateien = dateien To make this work, the declaration of the property dateien (line 19 of ContentView4) needs to be var, not let. By the way, why are you adding Optional to the property declaration of dateien?     let dateien = Optional(["word.png", "vi.png", "text.png", "pp.png", "pdf.png", "ordner.png", "ex.png", "datei.png", "bild.png"]) With declaring it as non-Optional, you can reduce some risky-and-never-want-to-use forced unwrappings (!).     var dateien: [String] = [] Or if you need some initial values:     var dateien: [String] = ["word.png", "vi.png", "text.png", "pp.png", "pdf.png", "ordner.png", "ex.png", "datei.png", "bild.png"]
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’21
Reply to Question: Swiftui http request without button
"Cannot use mutating member on immutable value: 'self' is immutable." Sorry, I have forgotten one thing. In struct used as View, you need @State in addition to making it var:     @State var dateien = ["word.png", "vi.png", "text.png", "pp.png", "pdf.png", "ordner.png", "ex.png", "datei.png", "bild.png"] (Seems I need to repeat, remove Optional.) Also, you need to remove mutating from doHttpRequest().
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’21
Reply to What is the type of a constant that is being implemented into a custom modifier?
In Swift, type names should start with Capital letter. If you have some reason that you cannot follow the basic coding rule of Swift, please re-interpret the following description. You declare icon in your SettingsIconImageStyleUsingSFSymbols as a concrete struct type RowAndIconView. Then there is no choice other than you declare it as RowAndIconView: import SwiftUI struct SettingsIconImageStyleUsingSFSymbols: ViewModifier { 		let icon: RowAndIconView 		func body(content: Content) -> some View { 				Image(icon.systemImageName) 						.resizable() 						.aspectRatio(contentMode: .fit) 						.frame(width: 35, height: 35) 						.padding(7) 						.foregroundColor(icon.foregroundColorOfImage) 						.background(icon.backgroundColorOfImage) 						.cornerRadius(10) 						.padding(5) 		} } extension View { 		func settingsIconViewWithSFSymbols(with icons: [RowAndIconView]) -> some View { self.modifier(SettingsIconImageStyleUsingSFSymbols(icon: icons[0])) 		} } //Or extension View { 		func settingsIconViewWithSFSymbols(with icon: RowAndIconView) -> some View { self.modifier(SettingsIconImageStyleUsingSFSymbols(icon: icon)) 		} }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’21