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

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
1 vote
0 answers
44 views

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
1 vote
0 answers
50 views

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
85 views

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

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

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
3 votes
1 answer
70 views

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
1 answer
78 views

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
5 votes
1 answer
710 views

I have implemented the Caesar Cipher in Swift and incorporated it into an iOS-app. I guess it's formally correct. Please see the attached images, which show how the usage of the app is meant. Here's ...
michael.zech's user avatar
  • 5,044
2 votes
1 answer
216 views

Task description: Implement a function, which receives an array of unsorted numbers from 1 to 100. In the array zero or more numbers might be missing. The function shall return an array containing the ...
michael.zech's user avatar
  • 5,044
1 vote
1 answer
191 views

Task: Implement a function, which accepts two integers and results the first number raised to the power of the second number. Both numbers have to be positive. Examples: The arguments 4 and 3 shall ...
michael.zech's user avatar
  • 5,044
4 votes
1 answer
94 views

I want to download an XML and check to see if it can be parsed at all, no schema validation. I was thinking to write two free functions, to separate concerns and wrap them in a third, public API: <...
Dan's user avatar
  • 165
6 votes
1 answer
527 views

The task is writing a function, which checks if a string contains only unique characters. Means: is each character is included only one time. Here's the solution, I have developed: ...
michael.zech's user avatar
  • 5,044
3 votes
2 answers
142 views

I am building this pet project with UIKit. The App's main goal is to keep track of my daily expenses. The AddExpenseViewController is responsible for capturing user ...
motita's user avatar
  • 31
3 votes
1 answer
189 views

I am trying to find a way to search an Int array (all numbers are > 0) and identify sequences where the sum of each element is a specific number. One element can ...
koen's user avatar
  • 179
4 votes
1 answer
138 views

This code finds highly composite numbers (numbers with more factors than any smaller number) in Swift. I'm not too familiar with Swift, I did this in python but it was too slow so I decided to try it....
Octobass's user avatar
3 votes
1 answer
158 views

I have been trying to solve Trie related problems over at leet code and came across this interesting problem 211. Design Add and Search Words Data Structure Here is the question for convenience: 211. ...
Shawn Frank's user avatar
3 votes
0 answers
200 views

This work is motivated by Sum of natural numbers below threshold, where several Swift solutions to Project Euler #1 (with arbitrary upper bound) are provided. One way to think of it is to start with ...
Martin R's user avatar
  • 24.2k
5 votes
1 answer
136 views

I have the following function in Swift and am looking to improve the readability. The function takes from the deviceData object which holds maps of data like ...
Dylon Jaynes's user avatar
2 votes
1 answer
288 views

I'm currently trying to find out what's the best networking architecture for MVVM applications. I couldn't find many resources and decided to go with dependency injection based architecture as per the ...
Tharindu Ketipearachchi's user avatar
3 votes
1 answer
992 views

getFinalImageData(:UIImage) takes a UIImage and downscales its size dimensions (to 400 ...
ctrl freak's user avatar
2 votes
1 answer
391 views

just wanted someone to review my code and perhaps simplify it a bit. Everything is working as expected for the moment but it seems too much code for what i'm trying to achieve. Especially the function ...
Bjorn Morrhaye's user avatar
1 vote
1 answer
185 views

Working through a book problem Write a function that accepts two values and returns true if they are isomorphic. That is, each part of the value must map to precisely one other, but that might be ...
Jakory's user avatar
  • 23
0 votes
1 answer
87 views

This question is carried over from StackOverflow... First time posting here, so bear with me. The topic is constructing a search made up of a given string, and a series of letters, where each of the ...
Dan Donaldson's user avatar
1 vote
1 answer
728 views

I have the following form that creates a new "activity": For which I want to enforce the following requirements: Name => minimum # of chars: 1; maximum # of chars: 50 Description => ...
Enrique's user avatar
  • 145

1
2 3 4 5
14