Skip to main content

Questions tagged [swift]

Swift is a general-purpose, multi-paradigm, compiled programming language developed by Apple Inc. for iOS, iPadOS, macOS, watchOS, tvOS, Linux, and z/OS.

1vote
0answers
43views

Refactoring NWBrowser in Apple's Tic-Tac-Toe example

I'm looking to refactor Apple's example code used in this WWDC talk. When turning on Swift 6 language support and complete concurrency checking, the project will not build due to: Capture of 'self' ...
Jim M's user avatar
4votes
3answers
322views

Swift - Process file with key-value pairs

I got to process a simple text-file, which contains key-value pairs. Key-value shall be separated by a tabulator. Here's the prototype, which I figured out: ...
michael.zech's user avatar
1vote
0answers
34views

SwiftUI NavigationSplitView three-column layout

For getting familiar with SwiftUI NavigationSplitView, I created a prototype, which implements a three-column view. Screenshot: Code (View): ...
michael.zech's user avatar
0votes
0answers
33views

Class to make UserDefaults get/set easier in Swift

I created the following class to ease UserDefaults get/set within my Swift project. ...
geohei's user avatar
1vote
0answers
50views

SwiftUI: Handling number-inputs via TextField (actually String)

I'm creating a Settings-form in SwiftUI. One of the expected values is a double. I tinkered with NumberFormatter, but it didn't work well for me. Moreover I had to find a way making invalid values ...
michael.zech's user avatar
6votes
1answer
192views

Showing an audio waveform from sample audio data with user interaction for zoom in/out

I want to show an interactive audio waveform like this. I've extracted the sample data using AVAssetReader. Using this data, I'm drawing a UIBezierPath in a Scrollview's contentView. Currently, when I ...
Ahsan Habib Swassow's user avatar
3votes
1answer
97views

Swift Arrays: Write a rotate-right function

Task: Write a function which rotates all elements of a given array to the right. Example: [1, 2, 3] => [3, 1, 2] My solution: ...
michael.zech's user avatar
4votes
2answers
175views

Swift String-extension 'countOccurrencesOfChar'

Loosely inspired by Ruby's String.count-method I wrote a similar Swift-method myself as an extension to the String-class. Then I had the idea to use a second parameter with which you can control if ...
michael.zech's user avatar
3votes
1answer
96views

Swift: 'Working with double-optionals'-exercise

Task: Write a function, which receives an optional array of optional integers and returns a none-optional integer. In case the array isn't nil: Return one randomly selected integer. In case the array ...
michael.zech's user avatar
4votes
1answer
217views

SwiftUI TimeUnits-Converter App

The given task is to implement a time-units app. I guess I got the main logic right, but concerning the UI-coding there could be improvements. Here's my code: ...
michael.zech's user avatar
3votes
1answer
54views

Swift: Mocking a REST API-request

I have read the last two days through several tutorials about how to mock a HTTP-request against a REST API. Finally I made a prototype for applying, what I have understood from the tutorials. Here's ...
michael.zech's user avatar
0votes
0answers
43views

Idiomatic SwiftUI, a combination picker and presenter

I am learning Swift & SwiftUI after 15 years doing VBScript & PowerShell. My current learning project is Stewart Lynch's BookList based on SwiftData. And as part of that project he has a View ...
Gordon in Ukraine's user avatar
3votes
2answers
375views

Write a Swift-function, which computes the Digital Root

Task: Write a function, which computes the Digital Root of a given number n. Here's the solution, which I developed: ...
michael.zech's user avatar
3votes
1answer
54views

Lists With Generic Data Types In SwiftUI

I've written a simple list in SwiftUI that accepts a generic data type. The goal was to make a reusable list where when an item was selected, the list would execute a callback with the selected data. ...
dubbeat's user avatar
2votes
1answer
87views

Show a list of downloads

I've been working on a Swift project that involves a seedbox app for my NAS, and I would appreciate some feedback on the code structure and especially on the placement of my observer. I've implemented ...
Bam Bou's user avatar

153050per page
close