Post

Replies

Boosts

Views

Activity

How to fix MainActor warning for QLPreviewControllerDelegate
I'm currently migrating a midsize (20k LOC) project to Swift structured concurrency. With complete checking turned on, it currently builds with only two warnings, both of which are related to the QLPreviewControllerDelegate protocol: "Main actor-isolated instance method 'previewControllerDidDismiss' cannot be used to satisfy nonisolated protocol requirement; this is an error in the Swift 6 language mode" as well as the same warning but substituting 'previewController(_:transitionViewFor:)' for the method name. I'm confused as to how to make these nonisolated, as they use UIKit classes/subclasses as arguments and/or return types.
1
0
90
3d
Expose a Swift initializer as an Objective-C factory constructor
I'm creating a compatibility layer for a new Swift implementation of a legacy Objective-C library. The Objective-C library has a class whose only constructor is a factory constructor: (instancetype)fooWithBar:(NSString *)bar; I know that when bridging from Objective-C to Swift the factory constructors are turned into convenience initializers. But I'm trying to do the reverse, that is create a factory constructor for a Swift class. The convenience initializer gets turned into something along the lines of: (instancetype)initWithBar:(NSString *)bar; So my approach is to create a static method in Swift that returns an instance of Self: @objc static func foo(bar: String) - Self This gets exposed correctly, but I'm a little uneasy since it's clearly asymmetric with the Objective-C - Swift bridging, and also it returns an owned reference, where the Objective-C convention would be that a factory constructor returns an autoreleased object. Long story short, is the static func the way to go, and am I creating a memory leak here? (and if so, how should I fix it?)
1
0
607
Mar ’21
UISegmentedControl segments and VoiceOver
I'm using a UISegmentedControl to ask the user to select from a range of numbers. The start of the range is not necessarily at 1. When using VoiceOver, the segment that is focused reads the accessibilityLabel, followed by the accessibilityTrait ("button"), followed by the numeric position in the control ("x of y"), followed by the accessibilityHint. How can I change the "x of y" that's spoken between the trait and the hint? It's confusing when the user has just selected a segment labeled "10" and hears "ten. button. 11 of 11."
3
0
1.8k
Mar ’21