Skip to main content
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 ...
Martin R's user avatar
  • 23.3k
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 ...
Martin R's user avatar
  • 23.3k
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 ...
Daniel T.'s user avatar
  • 831
3 votes
Accepted

SwiftUI/Swift code for changing item values in an immutable struct

The toggleItems() function can be simplified to ...
Martin R's user avatar
  • 23.3k
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 ...
pawello2222's user avatar
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 ...
Roland Illig's user avatar
  • 21.3k
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.
MrO's user avatar
  • 121
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 ...
shreyasm-dev's user avatar
1 vote
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 “...
Rob's user avatar
  • 2,552
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 ...
Zonker.in.Geneva's user avatar
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 ...
Rob's user avatar
  • 2,552
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 ...
pawello2222's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible