Post

Replies

Boosts

Views

Activity

Reply to How to handle URL Image if has non English characters SwiftUI
its not display anything . Then your item.image is not what I expect. Are you sure it does not contain schemes like https:// as you have shown as an example? UPDATE i solved the problem. instead of .urlPathAllowed - urlQueryAllowed and it worked. Thank you so much for help. Happy to hear you solved your issue. If urlQueryAllowed worked, I guess your image contained scheme.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Mar ’21
Reply to Closure definition mismatch
I did not know that. Could you please provide an official document confirm that ? Submit your iOS and iPadOS apps to the App Store - https://developer.apple.com/news/?id=itpt8dkc Starting April 2021, all iOS and iPadOS apps submitted to the App Store must be built with Xcode 12 and the iOS 14 SDK. Before April 2021, you can use Xcode 11+ and the iOS 13+ SDK, but not Xcode 10.1.
Topic: Programming Languages SubTopic: Swift Tags:
Mar ’21
Reply to try to convert string to integer
You should better learn how to format your code here in the dev forums. (Use the icon ``.) Seems you have not read the Swift book - https://docs.swift.org/swift-book/ yet. Optional is one of the core concept in Swift language, so you should better learn it before writing codes in Swift. (There are several parts written about Optionals.) And one more thing you need to know is that Swift is a strongly typed language, meaning every variable has its own type. With declaring a variable as in your code: var nNumber = 0 This is equivalent to: var nNumber: Int = 0 The variable has a type Int. But the type of expression is OptionalInt (also written as Int?), as String to Int conversion may fail. You need to decide what to do when cString cannot be interpreted as an Int. If want to supply some default value, you can use nil-coalescing operator ??. (As shown in the Claude31's reply.) nNumber = Int(cString) ?? 0 The type of the expression Int(cString) ?? 0 is non-Optional Int and you can assign the value to the variable of type Int. By the way, prefixed identifiers like cString or nNumber are not preferred in Swift. You should better be accustomed to the Swift way.
Topic: Programming Languages SubTopic: Swift Tags:
Mar ’21
Reply to Is it possible for a macOS app to download and run a swiftUI view file?
Constraints: App will be served on the app store You may need to re-check the App Review Guidelines, especially this part: 2.5 Software Requirements - https://developer.apple.com/app-store/review/guidelines/#software-requirements.2 Apps should be self-contained in their bundles, and may not read or write data outside the designated container area, nor may they download, install, or execute code which introduces or changes features or functionality of the app, including other apps. Educational apps designed to teach, develop, or allow students to test executable code may, in limited circumstances, download code provided that such code is not used for other purposes. Such apps must make the source code provided by the Application completely viewable and editable by the user. Your app would be considered to be an educational app, but not designed to teach, develop, or allow students to test executable code. So, download and run a swiftUI view file would never be approved whether it is in a source file or some sort of compiled binary. If you can represent your packs in other format (for example, HTML & JavaScript), your app can be considered to be sort of packs player, and may have some chance to be approved. Sorry, just my opinion.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Mar ’21
Reply to Text cutting subscript character
If I add a subscript character to my Text view, SwiftUI is cutting it like if it's not calculating its size. How are you showing the subscript character? When I tried with some subscript characters like Text("xᵢ"), the content is presented properly.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Mar ’21
Reply to Food Tracker error (Yes, Again)
Should I finish this tutorial or stop following it? Depends on what you want to learn or whether you can find another better tutorial. Learning how to fix the bugs of a tutorial would be a good exercise for you, but it may not be an efficient way to learn programming, especially for people who are in an early stage of learning. Better find another.
Topic: Programming Languages SubTopic: Swift Tags:
Mar ’21
Reply to Decoding JSON from api
You can decode the result of the new API as [String: [Member]]: let request = URLRequest(url: url) URLSession.shared.dataTask(with: request) { data, response, error in if let data = data { do { // Using `try?` is not recommended... let response = try JSONDecoder().decode([String: [Member]].self, from: data) DispatchQueue.main.async { for (table, members) in response { print(table, members) //... } } } catch { print(error) } } }.resume()
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Mar ’21