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.

Filter by
Sorted by
Tagged with
5 votes
4 answers
250 views

Swift for CLI tools (traversing directories, reading text files)

To compare ergonomics and performance of some languages for my hobby projects, I have written a simple lines of code counter in Swift, Go, Rust and Python. It scans a given directory tree for source ...
user avatar
1 vote
0 answers
25 views

Using a ViewModel in a simple SwiftUI screen with a list and API call

I'm building a SwiftUI screen that displays a list of notifications, using a ViewModel to handle state and API calls. The screen is fairly straightforward: it has a header and a paginated notification ...
Bhavesh.iosDev's user avatar
4 votes
3 answers
360 views

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
  • 4,972
1 vote
0 answers
41 views

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
  • 4,972
0 votes
0 answers
36 views

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
  • 265
1 vote
0 answers
60 views

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
  • 4,972
6 votes
1 answer
203 views

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
4 votes
1 answer
102 views

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
  • 4,972
4 votes
2 answers
175 views

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
  • 4,972
2 votes
1 answer
97 views

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
  • 4,972
4 votes
1 answer
218 views

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
  • 4,972
3 votes
1 answer
60 views

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
  • 4,972
3 votes
2 answers
377 views

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
  • 4,972
3 votes
1 answer
60 views

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
  • 131
2 votes
1 answer
90 views

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
  • 21

15 30 50 per page
1
2 3 4 5
44