In trying to convert some Objective-C to Swift, I have a subclass of NSWindowController and want to write a convenience initializer. The documentation says
You can also implement an NSWindowController subclass to avoid requiring client code to get the corresponding nib’s filename and pass it to init(windowNibName:) or init(windowNibName:owner:) when instantiating the window controller. The best way to do this is to override windowNibName to return the nib’s filename and instantiate the window controller by passing nil to init(window:).
My attempt to do that looks like this:
class EdgeTab: NSWindowController
{
override var windowNibName: NSNib.Name? { "EdgeTab" }
required init?(coder: NSCoder)
{
super.init(coder: coder)
}
convenience init()
{
self.init( window: nil )
}
}
But I'm getting an error message saying "Incorrect argument label in call (have 'window:', expected 'coder:')". Why the heck is the compiler trying to use init(coder:) instead of init(window:)?
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Created
Does anyone know if the resources .copy rule in a Swift .package file is supposed to recursively copy the full contents if it's pointed at a directory?
The docs say…
If you pass a directory path to the copy rule, the compiler retains the directory’s structure.
…but you can interpret that in a few different ways.
It also doesn’t appear to work if the directory you specify only contains directories.
I want to use the Observations AsyncSequence on some SwiftData @Model instances to determine if internal calculations need to be done.
When a simple property is linked to the Observations it fires CONTINUOUSLY even though no change is made to the model property.
Also, when I try to observe a property which is a list of another @Model type the Observations sequence does not fire when I add or remove items.
I am hoping to use the async-algorithm's merge function so all the associated sequences can be combined since if any of the associated events should fire the calculation event.
I think that it would be helpful to have better interoperability between Swift and JavaScript. There are a lot of useful packages on NPM that don't have equivalents for Swift. It would be helpful if Apple provided easier ways to use NPM packages in a Swift project. Currently, the JavaScriptCore framework is missing many standard things used in many packages, like the fetch API. It would be helpful to be able to run sandboxed JavaScript code inside of a Swift app but allow access to specific domains, folders, etc., using a permissions system similar to Deno.
I am implementing the FFT using vDSP.DiscreteFourierTransform. According to the official documentation, the count parameter has requirements as outlined below:
/// The `count` parameter must be:
/// * For split-complex real-to-complex: `2ⁿ` or `f * 2ⁿ`, where `f` is `3`, `5`, or `15` and `n >= 4`.
/// * For split-complex complex-to-complex: `2ⁿ` or `f * 2ⁿ`, where `f` is `3`, `5`, or `15` and `n >= 3`.
/// * For interleaved: `f * 2ⁿ`, where `f` is `2`, `3`, `5`, `3x3`, `3x5`, or `5x5`, and `n>=2`.
Despite adhering to these specifications in theory, my attempt to initialize an interleaved DFT with count = 2 * 2 * 5 * 5 (equivalent to 5×5 × 2²) resulted in a failure. Below is the code snippet I used for the initialization:
do {
let dft = try vDSP.DiscreteFourierTransform(
previous: nil,
count: 2 * 2 * 5 * 5,
direction: .forward,
transformType: .complexReal,
ofType: DSPComplex.self
)
print(dft)
} catch {
print("DFT init failed:", error)
}
Could somebody more knowledgeable with these APIs have a look? Thanks!
I currently have a iOS app live on the App Store but I also want to release it on Android, the whole code is in Swift so would that be possible or would I have to rewrite my whole apps code in a different coding language.