6
votes
Accepted
Caesar Cipher in Swift (iOS-app)
My main point of criticism is that the encryption logic is in the view, actually in two views: the ContentView contains the code to shift one index forward or ...
5
votes
100DaysofSwiftUI - Project 1 - Challenge 1: Convert temperature units: Celsius, Fahrenheit and Kelvin
The conversion function convertedDegreeC2F() handles only four of the nine possible conversions between the three units. In particular, the conversion between ...
4
votes
Accepted
SwiftUI TimeUnits-Converter App
The conversion function should be separate from the UI, for example as a global function
...
3
votes
Structure and readability of the code in swift ios
First there's some low hanging fruit. Perpetual use of self. when not needed. Use of parens when not needed. Inconsistent formatting (sometimes you put a space ...
3
votes
Accepted
SwiftUI/Swift code for changing item values in an immutable struct
The toggleItems() function can be simplified to
...
3
votes
Break music player into usable components in SwiftUI
I need to ask a question when I break up my player into usable
components. How should I take this approach
The idea is to break a long and not so readable code into smaller parts. Also, each ...
3
votes
Lists With Generic Data Types In SwiftUI
It's fine as far as it goes:
The name and type in ListItem should not be ...
2
votes
Accepted
Display a Text() with a foreground color based on a condition
There is a shorter and faster way, using ternary operators.
You could use
...
2
votes
Accepted
Moving Timer from a View to a ViewModeller-class?
On the broader question of whether the timer should be pulled out of the view, itself, I would tend to agree.
It begs the question, though, whether it really belongs in a view model, either. If this “...
2
votes
100DaysofSwiftUI - Project 1 - Challenge 1: Convert temperature units: Celsius, Fahrenheit and Kelvin
The names of the measurement units are wrong. Kelvin does not take a degree. It's just K, not °K. Fixing this requires changes to most of the code.
It's a waste of computation time to calculate all ...
2
votes
Draw a spark line with SwiftUI
The role of your ZStack and border rectangle could be replaced with a .background or .overlay modifier on the Sparkline itself - would allow more flexibility in presentation at the point-of-usage.
1
vote
SwiftUI Reusable Login & Register View
As your code is not complete, it's hard to see exactly how your code works and therefore hard to make suggestions.
But here are my thoughts:
Yes, you should extract the buttons to a subview. It's not ...
1
vote
Use of parentheses in Swift
A few observations:
When using Booleans, we would generally not use the == true test, much less the parentheses. E.g. from The Swift Programming Language: The ...
1
vote
Accepted
SwiftUI Dot indicator
Your code is perfectly fine. Just a couple of comments:
It is bad-to-impossible to have any internal state in a View.
Actually SwiftUI was designed to handle state changes directly in a view. For ...
Only top scored, non community-wiki answers of a minimum length are eligible