Skip to main content
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: ...
Martin R's user avatar
  • 24.2k
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 ...
Eric Xue's user avatar
  • 173
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, ...
ielyamani's user avatar
  • 889
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.) ...
Martin R's user avatar
  • 24.2k
3 votes
Accepted

Notifying view controller of changes to any of five types of models

The type annotation in ...
Martin R's user avatar
  • 24.2k
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 ...
sundance's user avatar
  • 168
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 ...
Roman Podymov's user avatar
1 vote

Tableview Subclass implementing delegate datasource

Personally I don't like the way UITableViews work with a delegate and dataSource yet there's ...
Lucas van Dongen's user avatar
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 ...
muescha's user avatar
  • 288
1 vote

Finding the number of perfect squares in an array

You are not using the Swift array methods (map, filter, ...) ...
Eva Madrazo's user avatar
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 ...
Martin R's user avatar
  • 24.2k
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: ...
Senseful's user avatar
  • 111
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 ...
stevex's user avatar
  • 111

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