Posts

Post not yet marked as solved
1 Replies
5.1k Views
When using Task { ... } in Swift 5.5, I'm unclear if retain cycles might be an issue or not. For example: class ViewController: UIViewController { private var rows = [String]() private var tableView: UITableView? func populateRows() { Task { rows = (try? await getRowsFromNetwork()) ?? [] tableView?.reloadData() } } } Will populateRows retain the view controller for the life of the task because it references rows and tableView? If the view controller goes out of scope, I'd like it to have the freedom to deallocate without populateRows retaining it. This syntax compiles, but I don't know if it makes sense: class ViewController: UIViewController { private var rows = [String]() private var tableView: UITableView? func populateRows() { Task { [weak self] in self?.rows = (try? await self?.getRowsFromNetwork()) ?? [] self?.tableView?.reloadData() } } } I don't mind if the task continues to run. (I'm not worried about canceling it.) I just want to understand if there is a way to avoid retaining the view controller in the task, and if that happens automatically or if something like [weak self] is needed.
Posted
by thund3r.
Last updated
.
Post marked as solved
2 Replies
2.2k Views
In Xcode 11 I've created a binary xcframework written Swift. One of the public types that it defines is an enum, and it needs to be usable from Swift and Objecitve-C. So I added the @objc modifier like so:@objc public enum MyEnum: Int { case aaa case bbb }I import the xcframework into a separate Swift project and have the following switch statement:switch myEnum { case .aaa: break case .bbb: break }Unfortuntely compiling the switch statement produces this warning:"Switch covers known cases, but 'MyEnum' may have additional unknown values."If I were to define the enum in Objective-C instead of Swift, I would use NS_CLOSED_ENUM to ensure that there are no future cases, which would solve the Swift warning. But I don't know how to make a "closed enum" in Swift. Enums in Swift already are closed, but I think the @objc flag might be canceling that out in the interface.Can this be solved? Thanks in advance.
Posted
by thund3r.
Last updated
.
Post marked as solved
1 Replies
666 Views
I'd like to know about the use case where an iOS app depends on Facebook for its core functionality.When running the app, the user cannot proceed unless they sign in with Facebook. Once they sign in, the Facebook SDK is used for a variety of purposes that are core to the app's functionality. Without Facebook, the app has no purpose or usable features.Is Sign In with Apple required in this case?According to https://developer.apple.com/news/?id=06032019j"Sign In with Apple ... will be required as an option for users in apps that support third-party sign-in when it is commercially available later this year."
Posted
by thund3r.
Last updated
.
Post marked as solved
2 Replies
2.1k Views
If I have an ARView, is it possible to add SCNNode instances? I want to use Entity instances for some things and SCNNode instances for others. Ideally I'd like to have an SCNNode as a child of an Entity. I poked around the class hierarchy and I can't find a way.
Posted
by thund3r.
Last updated
.