Posts

Post not yet marked as solved
1 Replies
504 Views
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?)
Posted
by frankus.
Last updated
.
Post not yet marked as solved
3 Replies
1.5k Views
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."
Posted
by frankus.
Last updated
.
Post not yet marked as solved
1 Replies
481 Views
I have a Swift package that I created in Xcode 11.I wrote a unit test that tests a piece of coding using Scanner (NSScanner in Objective-C).The tests pass fine when run in Xcode, but running the same tests using swift test produces the following output:dyld: lazy symbol binding failed: Symbol not found: _$sSo9NSScannerC10FoundationE10scanStringySSSgSSF Referenced from: <path/to/test/target> (which was built for Mac OS X 10.15) Expected in: /usr/lib/swift/libswiftFoundation.dylibWhat am I doing wrong?
Posted
by frankus.
Last updated
.
Post not yet marked as solved
0 Replies
547 Views
Can one create a multi-component Picker in SwiftUI (where in UIKit the data source would return a number other than 1 from the numberOfComponents method)?I can fall back to an HStack of single-component Pickers, but the perspective effect is off.
Posted
by frankus.
Last updated
.