Post

Replies

Boosts

Views

Activity

Reply to Schedule start of notification requests
I'm a little confused as to what you mean by calling that function. Where would I call that function? And what is the requestItentifier in that function? Seems you do not know how to respond to user notifications. Please show your code instantiating your LocalNotificationManager.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Mar ’21
Reply to UIContextMenuConfiguration causes retain cycle
Thanks for showing your code and I could not reproduce the issue you described. Whether I include your code into a sample code of CollectionView, memory consumption does not show significant difference. One thing. I see deinit happens in popped ViewController but not with its CollectionView Cell. One possibility, your CollectionView Cell is causing the issue. Can you create a brand-new project, which is minimized just to reproduce the issue, and show full code of it? Steps needed to reproduce the issue would also be welcome.
Topic: UI Frameworks SubTopic: UIKit 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
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 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 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 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