7
votes
Finding the number of perfect squares in an array
Mathematical correctness
The used approach is incorrect for very large numbers, here is an
example:
...
4
votes
Water flowing swiftly over farmland – The August 2016 Community Challenge
I think this code is great. Using weak references to refer to a Basin is a great way to prevent retain cycles with automatic reference counting. One suggestion I ...
3
votes
Accepted
Quickselect algorithm in Swift
Let's start by updating this line to Swift 4.2 :
let pivotElement = a[Int.random(in: low..<high)]
In my tests, ...
3
votes
Accepted
Interview coding challenge for iOS Part 2 - the application in Objective-C and Swift
(The question is more than two years old, and both Xcode and Swift have been developed substantially in that time. The following review is written with the current Xcode 10.3 and Swift 5 in mind.)
...
3
votes
Accepted
Notifying view controller of changes to any of five types of models
The type annotation in
...
2
votes
Accepted
Prevent a UITextField from being input with aphabetic characters
If you want to disallow letters as input, why do you also test the old string of the text field? And why do you test, if the old and the new string contain a dot? The very simple solution to forbid ...
1
vote
Tableview Subclass implementing delegate datasource
This could be a good idea if you have 2 or more instances of UITableView with the same appearance in your app. Anyway it is better than to copy nearly the same code ...
1
vote
Tableview Subclass implementing delegate datasource
Personally I don't like the way UITableViews work with a delegate and dataSource yet there's ...
1
vote
Accepted
Swift UITableViewCell class to show cameras, ratings for a car wash and other information
here just my ideas how to improve your code. maybe in some points i am wrong, but this are the places i would dig into and make it a little better:
1) set Image only once
...
1
vote
Finding the number of perfect squares in an array
You are not using the Swift array methods (map, filter, ...)
...
1
vote
Project Euler problem #14 (longest Collatz chain) in Swift
Some suggestion to improve your code:
The global variables max and originalNum should be named differently to match their ...
1
vote
Extending CGPoint to conform to Hashable
Martin's answer is excellent. The one thing missing is how to extend CGPoint to conform to Hashable using the native hasher functions:
...
1
vote
UIAlertController and input validation
The aspect of it that I'd change is having to store the alertController as a property. This adds state to your class that will be stale when the alert is done unless you add more code to clear it. And ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
swift × 43swift3 × 43
ios × 13
cocoa × 4
beginner × 3
performance × 2
object-oriented × 2
programming-challenge × 2
functional-programming × 2
json × 2
primes × 2
generics × 2
authentication × 2
objective-c × 2
macos × 2
algorithm × 1
strings × 1
design-patterns × 1
time-limit-exceeded × 1
interview-questions × 1
hash-map × 1
regex × 1
api × 1
calculator × 1
mvc × 1