Skip to main content

Stack Exchange Network

Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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
2 votes
1 answer
115 views

Swift: Find neighbor-elements within an array

I need a function which finds the left and right neighbor-element within an integer-array, based upon a given index. If the given element is 0, then it shall return largest index as left neighbor. ...
michael.zech's user avatar
  • 5,044
5 votes
4 answers
268 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
32 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
370 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
  • 5,044
1 vote
0 answers
45 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
  • 5,044
1 vote
0 answers
44 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
  • 275
1 vote
0 answers
82 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
  • 5,044
6 votes
1 answer
213 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
109 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
  • 5,044
4 votes
2 answers
203 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
  • 5,044
2 votes
1 answer
105 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
  • 5,044
4 votes
1 answer
235 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
  • 5,044
3 votes
1 answer
65 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
  • 5,044
3 votes
2 answers
389 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
  • 5,044
3 votes
1 answer
71 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

15 30 50 per page
1
2 3 4 5
44
Morty Proxy This is a proxified and sanitized view of the page, visit original site.